动态添加script标签

let setScript = document.createElement("script");
setScript.setAttribute("type", "text/javascript");
setScript.setAttribute("src", "https://aaa");
setScript.setAttribute("id", "aa");
document.body.insertBefore(setScript, document.body.lastChild);
// 或者最后一句可跟换为
document.parentNode.insertBefore(setScript, document)


 

你可能感兴趣的:(js)