阅读量:128

小程序swiper根据页面长度滑动的案例:
在对应的js文件中添加以下代码:
get_wxml: function (className, callback) {
wx.createSelectorQuery().selectAll(className).boundingClientRect(callback).exec()
},
//获取节点信息
this.get_wxml(`#cont` + current, (rects) => {
console.log(rects)
let newHeight = rects[0].height
this.setData({
heights: newHeight
})
})
在对应的wxml文件中添加以下代码:
<!-- 导航栏 -->
{{item.name}} <!-- 页面 -->
{{item.name}}