<view class="centerTit" >
<text bindtap="chooseBtn" wx:for="{{tabitem}}" bindtap="setTab" data-tabindex="{{index}}" class="titWei">{{item.text}}</text>
<view class="tab-line" style="transform:translateX({{180*showtab}}%);"></view>
</view>
js:
data{
showtab: 0, //导航选项卡索引
tabitem: [
{
"id": 0,
"text": "商品"
},
{
"id": 1,
"text": "评价"
},
{
"id": 2,
"text": "详情"
},
]
}
// 导航滑动效果
setTab: function (e) {
const edata = e.currentTarget.dataset;
this.setData({
showtab: edata.tabindex,
})
},