wx.createSelectorQuery()的boundingClientRect()方法?

小程序 文章 2020-08-04 18:01 1512 0 全屏看文

AI助手支持GPT4.0

wx.createSelectorQuery()的boundingClientRect()方法?

boundingClientRect这个方法没有办法获取到wx:for里面元素高度,只要不是循环的数据就可以获取高度

The boundingclientrect method can't get the height of the element in Wx: for, as long as the data is not circular

回答:

子游:

可以页面写个和列表单元高度差不多的元素,然后乘以实际数量

张有釜:

可以在 列表 渲染之后的回调函数里 使用wx.createSelectorQuery()获取元素属性


列表是异步渲染的 你可能成功的打了一个时间差


丫头:获取的值是个空数组
Distance:

你给遍历循环的每个子元素加一个id,同一个id的也行,selecteAll

丫头:获取的值是个空数组

-EOF-

AI助手支持GPT4.0