锚点定位

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
const topTabList = [
{ name: '锚点一', point: 0 },
{ name: '锚点二', point: 0 },
{ name: '锚点三', point: 0 },
]
getScrollPoint(className) {
const systemInfo = uni.getSystemInfoSync()
let query = ''
// 在微信小程序中,如果把骨架屏放入组件中使用的话,需要调in(this)上下文为父组件才有效
// #ifdef MP-WEIXIN
query = uni.createSelectorQuery().in(this.$parent)
// #endif
// #ifndef MP-WEIXIN
query = uni.createSelectorQuery()
// #endif
query.selectAll(`.${className}`).boundingClientRect().exec((res) => {
res[0].forEach((v, i) => {
topTabList[i].point = v.top - v.height - 20 - (systemInfo.platform === 'ios' ? 44 : 48)
})
})
}

最后更新: 2021年09月28日 11:04