wx.createSelectorQuery()在ip6,ip7中获取的距离顶部的高度会偏下,刚开始几个差别不大后面的差的越来越大,xr和已测的安卓手机都是可以的,求指教
在setData的异步里面:调用的获取的方法: that.setData({ hairLabelList: lablelist, ['showSearchType.title']: lablelist[0].typeName, ['showSearchType.sex']: lablelist[0].sex, ['showSearchType.id']: lablelist[0].id, ['showSearchType.showType']: 0, }, () => { that.recordMargin() // 在当前同步流程结束后,下一个时间片执行 wx.hideLoading(); })
setTimeout(() => { this .data.hairLabelList.map((item, index) => { let selQuery = wx.createSelectorQuery(); selQuery.select( '#type' + index).boundingClientRect(); selQuery.exec(res => { if (!res[0]) return ; this .data.toTopList.push(res[0].top); console.log(res[0].top) }) }) }, 0) }, |
麻烦提供出现问题的具体机型的微信版本号、系统版本号,以及能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)
scrolling(e) {
console.log(
'点击获取的滚轮距离:'
,e.detail.scrollTop)
if
(
this
.data.openSelWindow)
return
;
let arr =
this
.data.toTopList;
let scrollTop = e.detail.scrollTop + 1;
arr.forEach((item, index) => {
if
(item <= scrollTop && scrollTop < arr[index + 1] &&
this
.data.showSearchType.title !=
this
.data.hairLabelList[index].typeName) {
console.log(
'进来了'
);
console.log(scrollTop);
console.log(
'---------'
)
this
.setData({
[
'showSearchType.title'
]:
this
.data.hairLabelList[index].typeName,
[
'showSearchType.sex'
]:
this
.data.hairLabelList[index].sex,
[
'showSearchType.id'
]:
this
.data.hairLabelList[index].id,
})
}
})
},
通过 scroll-view 的bindscroll属性绑定的