vue 中使用import导入 script 在线链接

一般我们在vue中导入另外一个文件或者文件中的方法,我们都是使用import来实现他的,那么问题来了,现在我们要导入的不是另外的一个文件,而是在线链接,这该怎么办?我们也使用了 import * as XX from 'http://www.baidu.com',这样我们也试过了没用,这该咋办呢,话不多说了,直接上代码!

index.vue

<template>
    <view>哈喽!你好</view>
</template>

<script>
    export default {
        mounted() {
            const s = document.createElement('script');
            s.type = 'text/javascript';
            s.src = 'https://z1-pcok6.kuaishangkf.com/bs/ks.j?cI=736107&fI=138249&ism=1';
            document.body.appendChild(s);
        }
    }
</script>

希望对你们有帮助哦!我是自己用过,可以才分享给大家的,希望能得到大家的👍!不好的话勿喷!

 

posted @ 2019-11-04 10:26  渺茫大海  阅读(4959)  评论(0编辑  收藏  举报