const query = uni.createSelectorQuery().in(this);
const forId = 'text-A';
query .select(`#${forId}`)
.boundingClientRect(data => {
console.log(data)
}).exec(res => {
console.log(res)
})
正常单次调用没有问题
当循环调用时,boundingClientRect会回调多次
所以要这样写
for (let item of iList) {
uni.createSelectorQuery().in(this).select(`#${forId}`)
.boundingClientRect(data => {
console.log(data)
}).exec(res => {
console.log(res)
})
}