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); }, |
看你这种情况,只有一个swiper-item,虽然有手势滑动的回弹效果,但其实是不能切换的,设置current啊,bindchange什么的意义也没有,再看你index始终都是等于iIndex的,所以只能显示111
你的意思是点击456的时候111111的地方出现456的内容,点击234出现234的内容??
https://developers.weixin.qq.com/s/c1CvVHm572cQ
点标题切换swiper-item?
你的意思是想根据点击<sroll-view>里的内容,实现<swiper>内容变化吗
swiper-item