如何根据下标切换swiper-item,标题是根据下标进行切换的,但在swiper显示不了效果?
view wx:for="{{datalist}}" wx:key="" wx:for-item="item" style=""> < scroll-view scroll-x scroll-with-animation scroll-left = "{{left}}" style = "padding-left: 26vw;overflow-x: auto;height: 90rpx;white-space: nowrap; font-size: 9pt;" > < view wx:for = "{{datalist}}" wx:key = "" wx:for-item = "item" style = "display: inline-block;width:17vw;height:10vw;line-height:10vw;font-size:26rpx;text-align:center;text-align:center;" class = "{{idIndex==index?'bottomBorder':''}}" bindtap = "itemList" data-index = "{{index}}" >{{item}}</ view > </ scroll-view > < swiper current = "{{currentTab}}" duration = "300" bindchange = "swiperTab" style = "height: 93vh;" > < swiper-item > < view wx:if = "{{idIndex==index}}" bindtap = "conIndex" data-index = "{{index}}" > 111111 </ view > </ swiper-item > </ swiper > |
itemList(e) { var that = this ; var index = e.currentTarget.dataset.index; var oLeft = e.currentTarget.offsetLeft; if (oLeft == 327) { this .setData({ left: 327, }) } else if (oLeft == 0) { this .setData({ left: 0, }) }; that.setData({ index: index, idIndex: index }) console.log(index + " " + that.data.idIndex); // if (that.data.currentTab == that.data.idIndex) { // return false; // } else { // that.setData({ // idIndex: index, // currentTab: index // }) // } }, conIndex: function (e) { var index = e.currentTarget.dataset.index; console.log(index); }, |