GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — 2.0版本API

2.0版本API

Jump to bottom
樊小书生 edited this page Dec 13, 2018 · 3 revisions

steps

介绍

steps.js是基于原生JavaScript的组件,可用于展示步骤条、时间轴等,功能支持:

  1. 自适应
  2. 支持横向和纵向显示,并且横向还支持居中显示
  3. 支持自定义间距
  4. 线、标题、描述、自定义等可自由排序
  5. 支持数字和圆点及自定义图标,也可以使用图片
  6. 如果标题和详情还不足以满足您的需求,你还可以插入自定义的html代码
  7. 如果样式不满意,可以加入自定义的父类class,然后根据css的权重重新定义样式

demo地址:http://www.fxss5201.cn/project/plugin/steps/2.0/

浏览器支持情况

https://caniuse.com/#search=flex, 由于布局中主要使用的是flex布局,所以支持IE10以上以及现代主流浏览器。 建议使用前先在你所要用的浏览器上查看demo:http://www.fxss5201.cn/project/plugin/steps/2.0/ 。

资源

首先需要引入样式文件steps.css:

<link rel="stylesheet" href="steps.css">

接下来引入steps.js:

<script src="steps.js"></script>

使用

在使用的时候,需要一个容器,例如:

<div id="steps1"></div>

然后在 JavaScript 中进行初始化:

var steps1 = steps({
    el: "#steps1",
    data: [
        { title: "步骤1", description: "111" },
        { title: "步骤2", description: "222" },
        { title: "步骤3", description: "desc步骤3步骤3" }
    ],
    active: 1,
    dataOrder: ["title", "line", "description"]
});

参数

参数名 类型 默认值 描述
el String "" 需要将steps渲染在何处,建议使用id,可以保证唯一性
data Array [] 渲染的数据
props Object title: "title", description: "description", status: "status", customHtml: "customHtml" 后面会详细描述
space Number null 两个之间的间距,默认是自适应
direction String "horizontal" steps是横向还是纵向
iconType String "number" 主轴线上的icon显示类型,支持"number"、"bullets"、"custom"
dataOrder Array ["line", "title", "description"] 设置线、标题、描述显示顺序
dataWidth Array [] 此属性仅在direction="vertical"时有效,按照 dataOrder 的显示顺序设置每个的默认宽度,如果未设置,则默认宽度,如果纵向显示左侧内容长度不一致,建议强制设置此属性,并且此属性的值建议使用flex的值,例如'1 0 100px'
center Boolean false steps是否居中显示,仅在direction==horizontal时生效
active Number 0 当前活动项,仅在data中未指定status时生效,否则自动废除
defaultClass String "step-default-class" 会在每个step上添加此class类名,方便自定义样式
finishClass String "step-finish-class" 会在每个step完成时添加此class类名,方便自定义样式
finishLine Boolean true 是否开启线条颜色的变更,在完成的时候线条会相应变色,仅在active有效时有效,也就是说在data中设置status参数时,将失效
finishLineClass String "step-finish-line-bg" 会在每个step完成时在之前的线条上添加此class类名,方便自定义样式
customClass String "" 会在最外层元素上添加此class类名,方便自定义样式

data参数说明:

参数名 类型 描述
title String 标题
description String 描述
status Number 状态,0表示未完成,1表示已完成,可选
icon String 只有在iconType == custom时有效,也可以直接传html代码
customHtml String 如果上述参数还满足不了需求,可以直接传html代码

props参数说明

参数名 类型 默认值 描述
title String "title" 标题,用于指定data中的key
description String "description" 描述,用于指定data中的key
status Number "status" 状态,0表示未完成,1表示已完成,可选,用于指定data中的key
icon String "icon" 只有在iconType == custom时有效,也可以直接传html代码,用于指定data中的key
customHtml String "customHtml" 如果上述参数还满足不了需求,可以直接传html代码,用于指定data中的key

更多关于参数使用的例子请查看demo:http://www.fxss5201.cn/project/plugin/steps/2.0/

方法

如果data数据中没有设置status参数,则提供以下的两个方法获取和设置当前的active:

setActive(number)

steps1.setActive(2);

重置active,如果data数据中含有status,则该方法自动废除。 number类型为Number,支持0~data.length

getActive()

steps1.getActive();

获取active,如果data数据中含有status,则该方法自动废除,返回值为当前的active。

Clone this wiki locally

You are visitor 01402809 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.