b***@163.com
b***@163.com
  • 发布:2022-09-14 13:32
  • 更新:2022-09-14 16:44
  • 阅读:679

Cannot read property 'createElement' of undefined at Vue.onLaunch

分类:uni-app

在App.vue里加载第三方库

onLaunch: function() {  
        var script = document.createElement('script');  
        script.src = 'https://g.alicdn.com/AWSC/AWSC/awsc.js';  
        document.body.appendChild(script);  
        console.log('App Launch');  
    },

运行到微信小程序开发工具后报错:

mp.runtime.esm.js?66fd:5817 TypeError: Cannot read property 'createElement' of undefined  
    at Vue.onLaunch (App.vue:9)  
    at invokeWithErrorHandling (mp.runtime.esm.js?66fd:1862)  
    at Vue.__call_hook (mp.runtime.esm.js?66fd:5873)  
    at Vue._vue.default.__call_hook (index.js?543d:1906)  
    at Me.onLaunch (index.js?543d:2031)  
    at Me.<anonymous> (WASubContext.js?t=wechat&s=1663129104986&v=2.26.0:1)  
    at new Me (WASubContext.js?t=wechat&s=1663129104986&v=2.26.0:1)  
    at r.<anonymous> (WASubContext.js?t=wechat&s=1663129104986&v=2.26.0:1)  
    at WASubContext.js?t=wechat&s=1663129104986&v=2.26.0:1  
    at createApp (index.js?543d:2147)(env: macOS,mp,1.06.2208010; lib: 2.26.0)

错误如图所示,请问如何解决?谢谢

2022-09-14 13:32 负责人:无 分享
已邀请:
CODE_XU

CODE_XU

小程序不支持 document

该问题目前已经被锁定, 无法添加新回复