selectAll中不能直接使用子组件的类名,需要使用 >>> 跨自定义组件的后代选择器
Tips: 万事不决,刷新解决(微信开发者工具)
参考:uniapp.dcloud.net.cn/api/ui/node…
let instance = getCurrentInstance()
let query = uni.createSelectorQuery().in(instance)
query
.selectAll('.blogDetail >>> .h2w__h1')
.boundingClientRect((data) => {
console.log('得到布局位置信息' + JSON.stringify(data))
})
.exec()