动态插入标签

addScript(){
let scriptArr = document.body.getElementsByTagName("script")
let runIn = true
for(var i in scriptArr ){
if(scriptArr[i].src == previewApi){
runIn = false
break;
}
}
if(runIn){
const s = document.createElement('script');
s.type = 'text/javascript';
s.src = previewApi;
document.body.appendChild(s);
}
}
posted @ 2019-06-17 15:23  Emma.Zhao  阅读(254)  评论(0编辑  收藏  举报