把uni.createSelectorQuery这个API放到nextTick里面一定报错

- 发布:2025-04-10 14:51
- 更新:2025-04-10 15:09
- 阅读:79
产品分类: uniapp/小程序/微信
PC开发环境操作系统: Windows
PC开发环境操作系统版本号: win10
HBuilderX类型: 正式
HBuilderX版本号: 4.57
第三方开发者工具版本号: RC 1.06.2503281
基础库版本号: 3.8.0
项目创建方式: HBuilderX
操作步骤:
预期结果:
不会报错才对
不会报错才对
实际结果:
UnhandledPromiseRejection: TypeError: Cannot read property '$scope' of null
14:48:11.879 at Object.newIn [as in] (http://127.0.0.1:34147/appservice/common/vendor.js:6368:19)
14:48:11.879 at Object.<anonymous> (http://127.0.0.1:34147/appservice/pages/index/index.js:17:65)
UnhandledPromiseRejection: TypeError: Cannot read property '$scope' of null
14:48:11.879 at Object.newIn [as in] (http://127.0.0.1:34147/appservice/common/vendor.js:6368:19)
14:48:11.879 at Object.<anonymous> (http://127.0.0.1:34147/appservice/pages/index/index.js:17:65)
bug描述:
想要防止onMounted获取不到元素,把uni.createSelectorQuery这个API放在nextTick函数里面,导致了报错