💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
[TOC] ## 类似于jquery的查询器 > 仅用于获取元素的`宽高`以及`位置`信息 > select() 返回1个节点 > selectAll() 返回多个节点 ``` <template> <view> <view class="title" id="wk">sss</view> <view class="title" id="wk2">sss</view> </view> </template> <script> export default { onReady() { this.getInfo() }, methods: { getInfo(){ let query = uni.createSelectorQuery().in(this); // 获取 元素的位置信息 query.selectAll('.title').boundingClientRect(data=>{ console.log('多个节点信息:') data.map(item=>{ console.log("left:" + item.left + ",right:" + item.right + ",top:" + item.top + ",bottom:" + item.bottom); }); }).exec(); // 获取 元素高度和宽度 query.select('#wk2').fields({size: true,scrollOffset: true}, data => { console.log("得到节点信息" + JSON.stringify(data)); console.log("width:" + data.width + ", height:" + data.height); }).exec(); } } } </script> <style> .title{line-height: 2em;padding: 20px;} </style> ``` > 参考资料:https://uniapp.dcloud.io/api/ui/nodes-info