在实际开发中会遇到需要引入外部JS的情况,使用在index.html里直接引入是可以的,但是无疑不是最好的选择,经过查阅各种资料,最后经过实际实验采用以下办法解决:
1、在vue文件里引入
<template><div id="indentify-code"><remote-js cdn="/sd/ncpc/nc.js?t=05"></remote-js></div><div id="indentify"></div></template>
2、js部分
......components: {'remote-js': {render() {return h('script', {//attrs: {type: 'text/javascript',src: this.cdn//}})},props: {cdn: {type: String,required: true}}}}......
如果觉得《VUE引入外部JS的方法》对你有帮助,请点赞、收藏,并留下你的观点哦!