如何动态引入js库

<script>
var str ="http://ldy2.zaoliedu.com/jquery1.12.4.js";
var _script=document.createElement('script');
_script.setAttribute('type','text/javascript');
_script.setAttribute('src',str);
document.getElementsByTagName('body')[0].appendChild(_script);
</script>

当时做一个修改器,可以让运营随时更换里面的跳转链接和关键字,然后到第三方库和 统计的时候碰到问题,就发现了 这个方法。可以用变量随时更换引入。

猜你喜欢

转载自www.cnblogs.com/koukoubujiajun/p/10219620.html