codecamp

百度智能小程序 步骤条

steps 步骤条

解释: 步骤条组件,可配置步骤条内容,步骤条状态,步骤条上限为8步。适用于信息输入,并可放置在页面的任何位置。

属性说明

属性名 类型 必填 默认值 说明

steps

Array

步骤条数据,最多支持8个步骤。steps示例:[{text: '标题文案标题文案标题文案'}, {text: '标题文案标题文案标题文案'}],详细代码请阅读代码示例

active

Number

1

当前步骤进度

color

String

#ccc

步骤条默认颜色

activeColor

String

#2b99ff

当前进度步骤条颜色

steps-class

String

提供步骤条的扩展样式类,供开发者自定义组件样式,可通过此class改变步骤条外层样式

step-class

String

提供步骤条的扩展样式类,供开发者自定义组件样式,可通过此class改变步骤条内容样式

step-main-class

String

提供步骤条的扩展样式类,供开发者自定义组件样式,可通过此class改变步骤条文本样式

示例 

在开发者工具中打开


代码示例

<view class="wrap">
    <view class="card-area">
        <view class="top-description border-bottom">默认样式</view>
        <view class="border-bottom">
            <smt-steps
                active="{{stepsActive}}"
                line-style="solid"
                steps="{{steps}}"
                active-color="#2772fb"
                step-main-class="step-main"
            >
            </smt-steps>
        </view>
        <button
            bindtap="addStep"
            class="step-btn-cls"
            hover-stop-propagation="true"
            type="primary"
        >
            点击按钮添加步骤
        </button>
    </view>
    <view class="card-area">
        <view class="top-description border-bottom">执行展示</view>
        <view class="border-bottom">
            <smt-steps
                active="{{fourStepsActive}}"
                line-style="solid"
                steps="{{fourSteps}}"
                active-color="#2772fb"
                step-main-class="step-main"
            >
            </smt-steps>
        </view>
        <button
            bindtap="changeActive"
            class="step-btn-cls"
            hover-stop-propagation="true"
            type="primary"
        >
            点击按钮执行步骤
        </button>
    </view>
</view>
Page({
    data: {
        stepsActive: 2,
        steps: [
            {
                text: '第1步'
            },
            {
                text: '第2步'
            }
        ],
        fourStepsActive: 2,
        fourSteps: [
            {
                text: '第1步'
            },
            {
                text: '第2步'
            },
            {
                text: '第3步'
            },
            {
                text: '第4步'
            }
        ]
    },

    /**
     * 添加步骤条进度
     */
    addStep() {
        const {stepsActive, steps} = this.data;
        const len = steps.length;

        if (len < 8) {
            this.setData({
                steps: [
                    ...steps,
                    {
                        text: `第${len + 1}步`
                    }
                ],
                stepsActive: stepsActive + 1
            });
        }
        else {
            this.showToast('步骤添加已到上限');
        }
    },

    /**
     * 展示提示
     *
     * @param {string} title 提示内容
     */
    showToast(title) {
        swan.showToast({
            title,
            icon: 'none'
        });
    },

    /**
     * 执行步骤
     */
    changeActive() {
        const {fourStepsActive, fourSteps} = this.data;
        if (fourStepsActive < fourSteps.length) {
            this.setData({
                fourStepsActive: fourStepsActive + 1
            });
        }
        else {
            this.showToast('步骤已执行完成');
        }
    }
});
.wrap {
    background-color: #f5f5f5;
    height: 100vh;
}

.step-main {
    display: flex;
    justify-content: center;
}

.step-main view {
    margin-left: 0 !important;
}

.step-btn-cls {
    background-color: #2772fb !important;
    color: #fff;
}
{
    "navigationBarTitleText": "步骤条",
    "navigationStyle": "default",
    "usingComponents": {
        "smt-steps": "@smt-ui/component/src/steps"
    }
}


百度智能小程序 图片上传器
百度智能小程序 日历
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

百度智能小程序开发文档

百度智能小程序 组件

百度智能小程序 地图

百度智能小程序 画布

百度智能小程序 API

百度智能小程序 界面

百度智能小程序 关注小程序引导组件

百度智能小程序 自定义组件

百度智能小程序 媒体

百度智能小程序 设备

百度智能小程序 拨打电话

百度智能小程序 内存警报

百度智能小程序 手机联系人

百度智能小程序 用户截屏事件

百度智能小程序 第三方平台

百度智能小程序 开放接口

百度智能小程序 百度收银支付

百度智能小程序 分包预下载

百度智能小程序 数据分析

百度智能小程序 服务端

百度智能小程序 云开发

百度智能小程序 初始化

百度智能小程序 云函数

百度智能小程序 服务端初始化

百度智能小程序 服务器获取上下文

百度智能小程序 服务端云函数

百度智能小程序 开发教程

百度智能小程序 功能开发

百度智能小程序 基本原理

百度智能小程序 小程序自动化

百度智能小程序 视频教程

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }