2953关注9986浏览
组件 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"
}
}
-
至过去的我
2044人对此回答表示赞同
我是未来的你,你现在是不是在年找寻小程序答案。你不要感觉诧异,给你来信原因,就是让你不在后悔。今天去学习如何推广小程序,相信......点击查看更多> -
SweetyAriana
4人对此回答表示赞同
同样报错
展开40回复分享发布于 6年前评论(0)
收起评论
-
Gianna
3人对此回答表示赞同
麻烦给个相关的代码片段,我们定位下问题
展开32回复分享发布于 6年前评论(2)
收起评论
-
大耳朵图图 2019-02-06 11:49
我也遇到开发工具selectQuery在重启时抛出warning不执行exec的问题,刷新后才正常的问题,并且在小程序真机上重启时也会偶发。wechatide://minicode/QsGPOcm4712y
回复 -
周翰 2019-02-08 23:18
定位到问题是在基础库升到2.1.0后出现的,2.0.9运行正常
回复
-