Component({
methods: {
getRect() {
this.success = ""; //换一个名字,比如this._success就好使
// this.fail = "";
// this.complete = "";
var query = wx.createSelectorQuery().in(this);
query
.select(".wrap .content")
.boundingClientRect(function (res) {
console.log(res);
})
.exec();
},
},
});
在组件内部,给组件的success赋值(this.suceess,this.fail,this.complete),再调用boundingClientRect,回调函数不会执行。
报黄:An SelectorQuery call is ignored because no proper page or component is found. Please considering using `SelectorQuery.in` to specify a proper one.
在自定义组件或包含自定义组件的页面中,应使用
this.createSelectorQuery()
来代替。