第一种直接获取该元素:
<view id="msgView"></view>
const query = uni.createSelectorQuery().in(this);
query.select('#msgView').boundingClientRect(data => {
console.log(data)
}).exec();
第二种循环获取元素:
如果需要在循环中找到对应宽高等等,需要在该id上加上标识,以便后面需要做对应的处理
<view class="limitCon" :id="'textHeight' + '-' + index + '-' + indexs">
<text>{{ items.value }}</text>
</view>
const query = uni.createSelectorQuery().in(_this);
query.selectAll('.limitCon').boundingClientRect();
query.exec((rects) => {
rects[0].forEach((rect, index) => {
console.log(rect)
});
});