2 回复
郁闷啊,
< swiper class = "swiper" current = "{{currentTab}}" duration = "200" bindchange = "swiperChange" bindanimationfinish = "animationfinish" > < swiper-item > < view id = "fist-swiper-item" >我是tab1---- index =1</ view > </ swiper-item > < swiper-item > < view >我是tab2---- index =2</ view > </ swiper-item > < swiper-item > < view >我是tab3---- index =3</ view > </ swiper-item > < swiper-item > < view >我是tab4---- index =4</ view > </ swiper-item > < swiper-item > < view >我是tab5----index = 5</ view > </ swiper-item > </ swiper > |
// swiper 滑动切换 swiperChange(e) { console.log(e.detail.current, 'e.detail.current' , e.detail, 'e.detail~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~' ) console.log( this .data.currentTab, '原来 this.data.currentTab-swiperChange~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`' ) var that = this if (e.detail.source == 'touch' ) { if (e.detail.current == 0 && that.data.currentTab > 1) { that.setData({ currentTab: that.data.currentTab }) } else if (e.detail.current == 0 && that.data.currentTab == 1) { wx.createSelectorQuery().select( '#fist-swiper-item' ).boundingClientRect( function (rect) { //rect.id // 节点的ID //rect.dataset // 节点的dataset //rect.left // 节点的左边界坐标 console.log(rect.left) }).exec() console.log(e) that.setData({ currentTab: e.detail.current }) } else { that.setData({ currentTab: e.detail.current }) } } }, |