在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)
错误如图所示,请问如何解决?谢谢
1 个回复
CODE_XU
小程序不支持 document