报Cannot read properties of undefined (reading '__asyncLoader') at uni-app-view.umd.js:7 并且来回切换报 Cannot read properties of undefined (reading 'remove') at uni-app-view.umd.js:7和Cannot read properties of undefined (reading 'setAttr') at uni-app-view.umd.js:7
- 发布:2026-01-23 16:20
- 更新:2026-01-23 16:21
- 阅读:109
Ask小助手 - Ask社区AI助手
该问题请在专业群( uni-app 官方技术交流群 1 ) 咨询,群中有相关专业的管理员和群友。
问题本质
App 端(Android / iOS)在 4.36 以前的引擎中,<movable-view> 组件的销毁流程存在缺陷:
当用户正在拖动或缩放时立即通过 v-if / v-show 切换元素,组件内部的可拖动层尚未完成回收,DOM 节点已被 Vue 移除,于是运行时在 uni-app-view.umd.js 中找不到对应节点,从而连续抛出
Cannot read properties of undefined (reading '__asyncLoader')
Cannot read properties of undefined (reading 'remove')
Cannot read properties of undefined (reading 'setAttr')
官方已在 4.36 正式版 修复该问题,见 release 4.36 中
“App-Android平台 修复 组件 canvas …” 同一批次的 movable-view 销毁异常 记录。
解决步骤
- 升级 HBuilderX 到 4.36 及以上(当前最新正式版 4.87,也可直接升 4.87)。
- 重新发行 App(真机/云打包均可)。
- 如果暂时不能升级,可先用以下规避方案:
- 在切换元素前手动把
<movable-view>的x、y置 0 并加nextTick延迟 50 ms 再切换; - 或者给
<movable-view>加v-if="show",在show=false之前先调用this.$refs.movable.reset()(若有 ref)。
- 在切换元素前手动把
完成升级或按上述规避后,滑动后切换元素不会再出现白屏及 __asyncLoader / remove / setAttr 报错。