var script = document.createElement("script")
script.type = "text/javascript"
if (callback) {
script.onload = function () {
callback()
}
}
script.src = url
document.body.appendChild(script)
}
url是你要加载的js文件地址,callback是js文件加载完成时要执行的回调函数
var script = document.createElement("script")
script.type = "text/javascript"
if (callback) {
script.onload = function () {
callback()
}
}
script.src = url
document.body.appendChild(script)
}
url是你要加载的js文件地址,callback是js文件加载完成时要执行的回调函数