本文实例为大家分享了微信小程序实现水平时间轴的具体代码,供大家参考,具体内容如下
1、wxml部分代码如下:
<view class="wehx-line-box">
<view class="weui-flex__item wehx-line-item" wx:for="{{axis}}" wx:key="*this">
<view class='line-name'>{{item.name}}</view>
<view class='weui-cell-list'>
<view class='line' style="background:{{item.star}}"></view>
<view class="dot {{item.finished?'dotActive':''}}"></view>
<view class='line' style="background:{{item.end}}"></view>
</view>
</view>
</view>
或者:
<view class="wehx-line-box">
<view class="weui-flex__item wehx-line-item">
<view class='line-name'>待成交</view>
<view class='weui-cell-list'>
<view class='line' style="background:none;"></view>
<view class="dot {{item.finished?'dotActive':''}}"></view>
<view class='line' style="background:{{item.end}}"></view>
</view>
</view>
<view class="weui-flex__item wehx-line-item">
<view class='line-name'>等待确认费用</view>
<view class='weui-cell-list'>
<view class='line' style="background:{{item.star}}"></view>
<view class="dot {{item.finished?'dotActive':''}}"></view>
<view class='line' style="background:{{item.end}}"></view>
</view>
</view>
<view class="weui-flex__item wehx-line-item">
<view class='line-name'>未付款</view>
<view class='weui-cell-list'>
<view class='line' style="background:{{item.star}}"></view>
<view class="dot {{item.finished?'dotActive':''}}"></view>
<view class='line' style="background:none;"></view>
</view>
</view>
</view>
wxss部分代码如下:
.wehx-line-box{
display: flex;
height: 90rpx;
border-top: 1rpx dashed #e5e5e5;
padding: 30rpx 0;
}
.wehx-line-item{
display:flex;flex-direction:column;justify-content:space-between;align-items:center;
}
.weui-cell-list{
display:flex;align-items:center;justify-content:space-between;width:100%;
}
.line{
width:43%;
height:2rpx;
background: #d5d8dd;
}
.dot{
border-radius: 50%;
width: 10px;
height: 10px;
margin-right: 4rpx;
background: #d5d8dd;
}
.dotActive{
background: #2ea7e0;
}
.line-name{
font-size:30rpx;
}
Js部分代码如下所示:
// pages/market/detail/detail.js
Page({
data: {
axis:[
{
name:'待成交',
star:'none',
end: '#d5d8dd',
},
{
name: '等待确认费用',
star:'#d5d8dd',
end: '#d5d8dd',
},
{
name: '未付款',
star:'#d5d8dd',
end: 'none',
},
]
},
onLoad: function (options) {
},
onReady: function () {
},
onShow: function () {
},
onHide: function () {
},
onUnload: function () {
},
onPullDownRefresh: function () {
},
onReachBottom: function () {
},
onShareAppMessage: function () {
}
})
最终效果如图所示:
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持编程网。