//方法1----------------------------------------
document.write(`<script src='js/external.js'></script>`);
//方法2----------------------------------------
/** 动态加载JS:
url 脚本地址
callback 回调函数
*/
loadJS(url, callback) {
let script = document.createElement("script");
script.type = "text/javascript";
script.src = url;
script.onload = script.onreadystatechange = function () {
if (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") {
callback && callback();
script.onload = script.onreadystatechange = null;
}
};
document.querySelector("html").appendChild(script);
},