console.log(this) const query = wx.createSelectorQuery(). in ( this ) query.select( '.pp-navbar__item' ).boundingClientRect( function (rect) { // this.sliderOffset = rect[1].width; // this.setData({ // sliderOffset:rect[1].width // }); console.log( this ) console.log(rect[0].width) }).exec() |
需求:想要获取节点的宽度,并传入data中,保存起来
报错
VM2604:1 An SelectorQuery call is ignored because no proper page or component is found. Please considering using `SelectorQuery. in ` to specify a proper one. |
我明明打印的出this,为什么还说我组件不明确?
我看官方文档也是这样写的呀
希望能得到解答,康萨迷大!
不用.in(this)
let query = wx.createSelectorQuery()
获取成功
Taro里面用 wx.createSelectorQuery() 成功。注意是wx, 不是Taro。
原来用Taro.createSelectorQuery()就不行。不知为啥
const query = wx.createSelectorQuery();
query.select(`#${this.canvasId}`)
我想问下解决了吗?放在onShow还是onReady?有用到定时吗?
你好请问解决了吗?我现在也遇到了
修改下,可先看下文档https://developers.weixin.qq.com/miniprogram/dev/api/wxml/wx.createSelectorQuery.html
_this2.createSelectorQuery is not a function;at pages/tabBar/login onShow function;at api getSetting success callback function
TypeError: _this2.createSelectorQuery is not a function