我是在上拉加载中调用的wx.createSelectorQuery()来获取dom位置信息,
let qid = '#ppt-' + cTab + '-' + 0 + '-' + (lasto)
let query = wx.createSelectorQuery()
query.select(qid).boundingClientRect()
query.exec(function (res) {
console.log(res[0].bottom)
})
如果我刚打开调试工具后上拉,调用会出警告如下:
VM54:1 An SelectorQuery call is ignored because no proper page or component is found. Please considering using `SelectorQuery.in` to specify a proper one.
然后我按照提示加了wx.createSelectorQuery().in(this)也不行
重新编译一下就不会报错了,不知道是什么问题?
崩溃。。
求救c⌒っ゚Д゚)っ

我也遇到这样的问题,顶一下,让官方看到。
我的代码
onLoad: asyncfunction(options) {varcurrentTabInDb = wx.getStorageSync(util.getCurrentPagePath() +':currentTab')if(currentTabInDb && currentTabInDb <= 2) {this.setData({currentTab: currentTabInDb ||this.data.currentTab})}this.setData({shopId: wx.getStorageSync('shopId')})awaitthis.refreshData(this.data.currentTab)this.adjustSwiperHeight()},adjustSwiperHeight: asyncfunction() {vartopTabsHeight = (await util.boundingClientRect('#topTabs')).heightvarviewportHeight = (await util.boundingClientRect(wx.createSelectorQuery().selectViewport())).heightvarlistHeight = (await util.boundingClientRect(`#list${this.data.currentTab}`)).heightvarminHeight = Math.max(listHeight, viewportHeight - topTabsHeight)this.setData({swiperHeight: minHeight +'px'})},util.boundingClientRect = selectorOrNodeRef =>newPromise((resolve, reject) => {varnodeif(typeofselectorOrNodeRef =='string'){node = wx.createSelectorQuery().select(selectorOrNodeRef)}else{node = selectorOrNodeRef}node.boundingClientRect(res => {resolve(res)}).exec()})也是tab这种形式,开发工具里面每次第一次打开都会出现这个错误,然后重新编译一次就好了。
客户端有时候会出现。
检查一下代码执行先后顺序,可能是组件初始化代码还没执行完就到你这里了
有可能,然后重新编译组件加载变快了,所以没问题,嗯,,,maybe
不对,是这样,我当时是打开,特意停了一段时间,才去上拉,触发的上拉加载,组件应该早加载完了
解决了吗,最近也遇到这个问题了,再真机只出现过两次。再控制台里console.log发现,query.exec方法没执行,再编译也没问题了,搞了一天了,试了各种方法,用API取到的设备像素比有的是错误的,也没办法用。在线等额。。。官方老爷快出来...
后面没有管,现在好像好了,我用了promise,但是不知道跟这个有没有关系
能否贴一下代码一览,我这边试了一下,还是不行,
//在onReachBottom后,获取每一列的高度,并调用 get_covtocol 更新列getprevH:function(cTab, where) {let that =thisconsole.log(where,'get tab',cTab,'previous height!')returnnewPromise((resolve, reject) => {let collists = that.data.collistlet colheights = that.data.colheightvari = 0, j = 0let lasto =''let done = [0,0]//console.log(collists,colheights)//创建节点选择器lasto = collists[cTab][0].length - 1colheights[cTab] = [-1, -1]if(lasto >= 0) {let qid ='#ppt-'+ cTab +'-'+ 0 +'-'+ (lasto)let query = wx.createSelectorQuery().in(that);//选择id//console.log(qid)query.select(qid).boundingClientRect()query.exec(function(res) {colheights[cTab][0] = res[0].bottomthat.setData({ colheight: colheights })done[0] = 1if(colheights[cTab][1] >= 0) resolve('done');//if (res[0].bottom < 0&&done[1]==1) reject('fail');})}lasto = collists[cTab][1].length - 1if(lasto >= 0) {let qid ='#ppt-'+ cTab +'-'+ 1 +'-'+ (lasto)let query = wx.createSelectorQuery();//选择idquery.select(qid).boundingClientRect()query.exec(function(res) {colheights[cTab][1] = res[0].bottomthat.setData({ colheight: colheights })done[1] = 1if(colheights[cTab][1] >= 0) resolve('done');})}});},这是我的获取组件的高度,我在onreachbottom这样调用的,其实我觉得好像没软用
that.getprevH(currentTab,'before more').then((value) => {that.get_covtocol(currentTab)});