我是在上拉加载中调用的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: async function (options) { var currentTabInDb = wx.getStorageSync(util.getCurrentPagePath() + ':currentTab' ) if (currentTabInDb && currentTabInDb <= 2) { this .setData({ currentTab: currentTabInDb || this .data.currentTab }) } this .setData({ shopId: wx.getStorageSync( 'shopId' ) }) await this .refreshData( this .data.currentTab) this .adjustSwiperHeight()
adjustSwiperHeight: async function () { var topTabsHeight = (await util.boundingClientRect( '#topTabs' )).height var viewportHeight = (await util.boundingClientRect(wx.createSelectorQuery().selectViewport())).height var listHeight = (await util.boundingClientRect(` #list${this.data.currentTab}`)).height var minHeight = Math.max(listHeight, viewportHeight - topTabsHeight) this .setData({ swiperHeight: minHeight + 'px' }) }, util.boundingClientRect = selectorOrNodeRef => new Promise((resolve, reject) => { var node if ( typeof selectorOrNodeRef == 'string' ){ node = wx.createSelectorQuery().select(selectorOrNodeRef) } else { node = selectorOrNodeRef } node.boundingClientRect(res => { resolve(res) }).exec() }) |
也是tab这种形式,开发工具里面每次第一次打开都会出现这个错误,然后重新编译一次就好了。
客户端有时候会出现。