Javascript Vue.js动态注入外部依赖项

Javascript Vue.js动态注入外部依赖项,javascript,vue.js,Javascript,Vue.js,我在vue.js中有一个站点,可以使用vue cli。当应用程序启动时,/js/app.js文件将加载并执行vue。我通过在我的index.html中添加链接来加载依赖项,如: <script type="text/javascript" src="http://localhost:3001/lib.umd.min.js"></script> 不理解依赖项,但html中存在链接。App Vue工作正常,但不依赖。请在安装的应用程序

我在vue.js中有一个站点,可以使用vue cli。当应用程序启动时,/js/app.js文件将加载并执行vue。我通过在我的index.html中添加链接来加载依赖项,如:

<script type="text/javascript" src="http://localhost:3001/lib.umd.min.js"></script>

不理解依赖项,但html中存在链接。App Vue工作正常,但不依赖。请在安装的应用程序挂钩中尝试:

mounted() {
 // get the scripts from your file and loop if needed
 // then for each one... 
 let myScript = document.createElement('script')
 myScript.setAttribute('src', 'https://some-rl.js') // url from file goes here
 document.head.appendChild(myScript)
}

不,这是一样的,脚本不是执行的
mounted() {
 // get the scripts from your file and loop if needed
 // then for each one... 
 let myScript = document.createElement('script')
 myScript.setAttribute('src', 'https://some-rl.js') // url from file goes here
 document.head.appendChild(myScript)
}