原生微信小程序步骤条横向 step

原生微信小程序步骤条横向 step

只有4个步骤的!没有多个
只有4个步骤的!没有多个
只有4个步骤的!没有多个

效果图如下=>

在这里插入图片描述
直接上代码吧

//在components文件夹中新建 steps 文件夹 wxml中
<view class="stepWrap">
    <view class="stepTit">{{stepList[stepIndex-1].step}}</view>
    <view class="flexCenter">
        <view class="flexCenter" wx:for="{{stepList}}" wx:key="step">
            <view class="number {{stepIndex-1>=index?'numActive':''}}">{{index+1}}</view>
            <view wx:if="{{index<stepList.length-1}}" class="line {{stepIndex-1 > index?'activeLine':''}}"></view>
        </view>
    </view>
    <view class="flexSpace">
        <view class="" wx:for="{{stepList}}" wx:key="step">
            <view class="stepMain">
                <view class="stepStit {{stepIndex-1>=index?'stitActive':''}}">{{item.step}}</view>
                <view class="timeBox">{{item.time}}</view>
            </view>
        </view>
    </view>
</view>
//js
Component({
  properties: {
    stepList: {
      type: Array,
      value: [
        {
          step:"买家下单",
          time:'2023-05-19 20:20:20'
        },
        {
          step:"买家下单",
          time:'2023-05-19 20:20:20'
        },
        {
          step:"买家下单",
          time:'2023-05-19 20:20:20'
        },
        {
          step:"买家下单",
          time:'2023-05-19 20:20:20'
        }
      ],
    },
    stepIndex: {
      type: Number,
      value: 3,
    },
  },
});

/* wxss 忽略字体*/

.flexCenter {
  display: flex;
  justify-content: center;
  align-items: center;
}
.flexSpace {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.stepWrap {
  background-color: #fff;
  padding: 36rpx 24rpx;
  margin-bottom: 20rpx;
  border-radius: 10rpx;
}
.stepTit {
  font-size: 36rpx;
  font-family: PingFangSC-Medium, PingFang SC;
  font-weight: 500;
  color: #1A1A1A;
  text-align: center;
  margin-bottom: 20rpx;
}
.stepMain {
  width: 120rpx;
  text-align: center;
}
.number {
  width: 48rpx;
  height: 48rpx;
  text-align: center;
  line-height: 48rpx;
  border-radius: 50%;
  border: 1rpx solid #ECECEC;
  margin: 0 auto;
}
.numActive {
  color: #fff;
  background: #0B78F2;
}
.stepStit {
  width: 120rpx;
  font-size: 24rpx;
  font-family: PingFangSC-Regular, PingFang SC;
  font-weight: 400;
  color: #787878;
  margin-top: 16rpx;
}
.stitActive {
  color: #0B78F2;
}
.timeBox {
  height: 48rpx;
  line-height: 24rpx;
  font-size: 20rpx;
  font-family: PingFangSC-Regular, PingFang SC;
  font-weight: 400;
  color: #787878;
}
.line {
  width: 125rpx;
  height: 2rpx;
  background: #ECECEC;
}
.activeLine {
  background: #0B78F2;
}

//页面中引用
//wx.json
{
    "usingComponents":{
        "step":"../components/steps"//组件位置
    }
}
//wxml
<view>
	//步骤条  stepList 格式见上 stepIndex 当前进行到哪一项
	<step stepList="{{stepList}}" stepIndex="{{stepIndex}}"/>
</view>
  • 2
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值