1.js新增dom進(jìn)行引入
mounted() {
? const s = document.createElement('script');
? s.type = 'text/javascript';
? s.src = '你的需要的js文件地址';
? document.body.appendChild(s);
}
2.組件式引入
export default {
? components: {
? ? 'remote-js': {
? ? ? render(createElement) {
? ? ? ? return createElement(
? ? ? ? ? 'script',
? ? ? ? ? {
? ? ? ? ? ? attrs: {
? ? ? ? ? ? ? type: 'text/javascript',
? ? ? ? ? ? ? src: '你的需要的js文件地址',
? ? ? ? ? ? },
? ? ? ? ? },
? ? ? ? );
? ? ? },
? ? },
? },
}