为什么在组件中用createSelectorQuery 获取不到元素信息

发布于 7 年前作者 guiyingwei16883 次浏览最后编辑 7 年前来自 ask

在引用得组件中

wx.createSelectorQuery().select(#id).boundingClientRect(function (rect) {

console.log(rect)

}).exec()



// 打印值为null

3 回复
heguiying
heguiying1 楼6 年前

你好,请具体描述问题出现的流程,并提供能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。

ping73
ping732 楼6 年前
    var query = wx.createSelectorQuery().in(this)
    query.select('#the-id').boundingClientRect(function(res){
      res.top // 这个组件内 #the-id 节点的上边界坐标
    }).exec()
fangshen
fangshen3 楼5 年前

页面中调用组件中的dom呢?