更新时间:2023-12-05 09:52:46
var js = document.createElement("script");
js.type = "text/javascript";
js.src = "path_to_the_file.js";
document.body.appendChild(js);
但这是异步的,所以你必须等到加载脚本才能使用它 -
but this is asynchronous, so you have to wait until the script is loaded to use it -
var js = document.createElement("script");
js.type = "text/javascript";
js.src = "path_to_the_file.js";
js.onload = function() {
//Code using this script here
};
document.body.appendChild(js);