添加js文件和删除js

onloadJS: function (url, callback) {
let script = document.createElement('script')
script.src = url
script.type = 'text/javascript'
document.getElementsByTagName('head')[0].appendChild(script)
script.onload = callback
},
removeJS: function (url) {
let scripts = document.getElementsByTagName('script')
for (let bb of scripts) {
if (bb.src.indexOf(url) > -1) {
document.getElementsByTagName('head')[0].removeChild(bb)
}
}
}
posted on 2017-11-29 16:19  XIE7654  阅读(2626)  评论(0编辑  收藏  举报