失眠网,内容丰富有趣,生活中的好帮手!
失眠网 > VUE引入外部JS的方法

VUE引入外部JS的方法

时间:2019-01-13 18:57:02

相关推荐

VUE引入外部JS的方法

在实际开发中会遇到需要引入外部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的方法》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。