let list = this.data.list;
let tabHeight = 0;
if (this.data.load) {
for (let i = 0; i < list.length; i++) {
let view = wx.createSelectorQuery().select("#main-" + i);//正常写法
//子组件写法 let view = wx.createSelectorQuery().in(this).select("#main-" + i);
view.fields({
size: true
}, data => {
list[i].top = tabHeight;
tabHeight = tabHeight + data.height;//子组件不加in(this),wx.createSelectorQuery()获取不到height
list[i].bottom = tabHeight;
}).exec();
}
this.setData({
load: false,
list: list
})
}
let scrollTop = e.detail.scrollTop + 20;
for (let i = 0; i < list.length; i++) {
if (scrollTop > list[i].top && scrollTop < list[i].bottom) {
this.setData({
VerticalNavTop: (i - 1) * 50,
TabCur: i
})
return false
}
}
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!