开发者工具升级到 1.02.1807120 SelectorQuery 异常
发布于 4 年前 作者 baiqiang 15826 次浏览 来自 问答

组件 ready() 方法调用 wx.createSelectorQuery() ,开发者工具打开项目时自动加载报警告信息且代码未正常执行,编译刷新后恢复正常;在微信手机端预览初次运行偶尔会出现。

我的项目中使用了很多 SelectorQuery 测量 element 尺寸来计算显示模式的代码,此问题会导致界面无法正常显示,希望能给出解决办法,非常感谢。

附出错信息:

An SelectorQuery call is ignored because no proper page or component is found. Please considering using `SelectorQuery.in` to specify a proper one.

截图:

代码:

// pages/TestComponent/TestComponent.js

Component({

ready() {

var query = wx.createSelectorQuery().in(this);

query.select(’.root’).boundingClientRect();

query.exec(res => {

console.log(res);

});

}

})

<!–pages/TestComponent/TestComponent.wxml–>

<view class=“root” />

// app.json

{

“pages”:[

“pages/TestComponent/TestComponent”,

“pages/index/index”

],

“window”:{

“backgroundTextStyle”:“light”,

“navigationBarBackgroundColor”: “#fff”,

“navigationBarTitleText”: “WeChat”,

“navigationBarTextStyle”:“black”

}

}

3 回复

Stable v1.02.1904090 同样有这样的问题,每次都报:

VM3308:1 An SelectorQuery call is ignored because no proper page or component is found. Please considering using `SelectorQuery.in` to specify a proper one.

麻烦给个相关的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html),我们定位下问题

同样报错

回到顶部