微信小程序自定义步骤条

编程入门 行业动态 更新时间:2024-10-28 08:23:29

微信小程序<a href=https://www.elefans.com/category/jswz/34/1771438.html style=自定义步骤条"/>

微信小程序自定义步骤条

  • steps.wxml 文件

 <view class="steps_box">

    <block class="block-step" wx:for="{{stepList}}">

      <view class="view_item">

        <icon wx:if="{{stepNum>=index+1?true:false}}" type="success" color="#3475b9" size="20" />

        <view wx:else> {{index+1}} </view><text style="color:{{stepNum>=index+1?'#3475b9':'#b6b6b6'}}">{{item.name}}</text>

      </view>

      <view wx:if="{{index==stepList.length-1?false:true}}" class="view_line {{stepNum<=index+1?'line_bgcolor1':'line_bgcolor'}} "></view>

    </block>

  </view>

  <view class="yh-btn active-btn" catchtap="numSteps" >下一步</view>

  • steps.js文件

  data: {

    stepList: [{

      name: '第一步'

    }, {

      name: '第二步'

    }, {

      name: '第三步'

    }, {

      name: '第四步'

    }, ],

    stepNum: 1, //当前的步数

  },

  numSteps() {

    this.setData({

      stepNum: this.data.stepNum == this.data.stepList.length ? 1 : this.data.stepNum + 1

    })

  },

  • steps.json 文件

      (无操作)

  • steps.wxss 文件

.yh-btn {

  border-radius: 10rpx;

  background: #3475b9;

  color: #fff;

  font-size: 30rpx;

  text-align: center;

  padding: 15rpx 0;

  margin: 20rpx;

  letter-spacing: 2rpx;

}

.active-btn:active {

  box-shadow: 0px 0px 10px #bbbec4 inset;

}

/* 步骤条 */

.steps_box {

  width: 100%;

  display: flex;

  align-items: center;

  justify-content: center;

  margin-top: 20rpx;

}

.block-step {

  display: flex;

  flex-direction: row;

  /* align-items: center;

  justify-content: center; */

}

.view_item {

  display: flex;

  align-items: center;

  justify-content: center;

  flex-direction: column;

}

.view_item text {

  font-size: 28rpx;

  margin-top: 20rpx;

  /* color: #909090; */

}

.view_item view {

  width: 36rpx;

  height: 36rpx;

  /* background-color: red; */

  border: 2rpx solid #b6b6b6;

  border-radius: 50%;

  display: flex;

  align-items: center;

  justify-content: center;

  color: #b6b6b6;

  font-size: 24rpx;

  content: "\e732";

}

.view_line {

  width: 15%;

  height: 2rpx;

  margin: 0rpx 2% 52rpx 0;

  background: linear-gradient(to right, #d3d2d3, #5fe7ff);

}

.line_bgcolor1 {

  background-color: #e0e0e0;

}

.line_bgcolor {

  background: linear-gradient(to right, #5fe7ff, #3475b9);

}

到这里就完结拉,欢迎留言使用~

效果图:

 

更多推荐

微信小程序自定义步骤条

本文发布于:2024-03-15 11:27:53,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1738787.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:自定义   步骤   程序   微信小

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!