收藏
回答

开发者工具升级到 1.02.1807120 SelectorQuery 异常

框架类型 问题类型 操作系统 工具版本
小程序 Bug macOS 1.02.1807120

组件 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 个回答

  • 晨
    2018-08-21

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

    2018-08-21
    有用
    回复 2
    • KaPeter
      KaPeter
      2018-08-21

      定位到问题是在基础库升到2.1.0后出现的,2.0.9运行正常

      2018-08-21
      回复
    • undefined
      undefined
      2018-09-05

      我也遇到开发工具selectQuery在重启时抛出warning不执行exec的问题,刷新后才正常的问题,并且在真机上重启时也会偶发。   wechatide://minicode/QsGPOcm4712y

      2018-09-05
      回复
  • daihong
    daihong
    2019-05-05

    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.

    2019-05-05
    有用
    回复
  • 2018-07-24

    同样报错

    2018-07-24
    有用
    回复
登录 后发表内容