提交 b6a64179 编写于 作者: H hdx

swiper-list2: 适配微信

上级 d7d57b21
......@@ -53,9 +53,11 @@
}
},
onReady() {
this.tabScrollView = this.$refs['tabScroll'] as UniElement
this.swiperWidth = (this.$refs["swiper"] as UniElement).getBoundingClientRect().width
this.tabScrollView = this.$refs['tabScroll'] as UniElement;
(this.$refs["swiper"] as UniElement).getBoundingClientRectAsync().then((res : DOMRect) => {
this.swiperWidth = res.width
this.updateTabIndicator(this.swiperIndex, this.swiperIndex, 1)
});
},
methods: {
onTabClick(index : number) {
......@@ -124,7 +126,15 @@
// 滚动到水平中心位置
const target_x = lerpNumber(current_node.offsetLeft, move_to_node.offsetLeft, percentage)
const center_x = target_x + move_to_node.offsetWidth / 2 - this.swiperWidth / 2
// app 平台后续支持 scrollTo()
// #ifndef MP-WEIXIN
this.tabScrollView!.scrollLeft = center_x
// #endif
// #ifdef MP-WEIXIN
this.tabScrollView!.scrollTo({
left: center_x
})
// #endif
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册