越王够贱
越王够贱
  • 发布:2020-12-01 17:54
  • 更新:2022-11-24 20:52
  • 阅读:4258

TypeError: Cannot read property '$vm' of undefined 跳转后出现此问题

分类:uni-app

在执行uni.switchTab 跳转到此页面后会再执行以下方法

const query = uni.createSelectorQuery().in(this);

就会出现这个错误

17:48:02.856 [system]TypeError: Cannot read property '$vm' of undefined
at a (http://localhost:8081/static/js/chunk-vendors.js:186:463928)
at v (http://localhost:8081/static/js/chunk-vendors.js:186:394436)
at Object.createSelectorQuery (http://localhost:8081/static/js/chunk-vendors.js:186:83074)
at VueComponent.loadViewHeight (webpack-internal:///C:\Users\Administrator\Desktop\RebateAPP\js\index.js:713:21)
at VueComponent.tabIndex (webpack-internal:///C:\Users\Administrator\Desktop\RebateAPP\js\index.js:133:12)
at Watcher.run (http://localhost:8081/static/js/chunk-vendors.js:8053:19)
at flushSchedulerQueue (http://localhost:8081/static/js/chunk-vendors.js:7795:13)
at Array.<anonymous> (http://localhost:8081/static/js/chunk-vendors.js:5424:12)
at flushCallbacks (http://localhost:8081/static/js/chunk-vendors.js:5350:14)
at <anonymous>

2020-12-01 17:54 负责人:DCloud_UNI_GSQ 分享
已邀请:
DCloud_UNI_GSQ

DCloud_UNI_GSQ

时机错误,onready后调用

  • 越王够贱 (作者)

    是在onread后调用的差不多页面加载后半分钟才调用 ,本身没有问题 ,但是有时候切换几遍就会出现这个问题

    2020-12-03 18:20

  • 越王够贱 (作者)

    而且 后面调用也会出问题

    2020-12-03 18:21

  • DCloud_UNI_GSQ

    回复 越王够贱: 有没有相关的测试工程和 测试步骤

    2020-12-03 18:26

  • tikyz

    回复 DCloud_UNI_GSQ: 这问题后来解决了吗

    2022-04-19 02:15

隆里电丝

隆里电丝

uni.createSelectorQuery() 要在需要在生命周期 mounted 后进行调用

l***@163.com

l***@163.com

也遇到了这个问题 请问是怎么解决的

要回复问题请先登录注册