您当前的位置: 首页 > 

js文件中引入另一个js文件

彭世瑜 发布时间:2020-06-08 10:21:22 ,浏览量:3

function importScript(scriptUrl){
    var script= document.createElement("script");
    script.setAttribute("type", "text/javascript");
    script.setAttribute("src", scriptUrl);
    document.body.appendChild(script);
}


importScript("https://unpkg.com/axios/dist/axios.min.js")

执行importScript 之后不能马上拥有对象,需要等待网络请求

参考 https://blog.csdn.net/qq_42249896/article/details/90769809

关注
打赏
1688896170
查看更多评论

彭世瑜

暂无认证

  • 3浏览

    0关注

    2727博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文
立即登录/注册

微信扫码登录

0.1275s