我是 stackoverflow 的新手,对于任何错误的提问方式,我提前表示歉意。
最佳答案
通过ajax:
let xhr = new XMLHttpRequest();
xhr.open('GET', 'test.js');
xhr.send();
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status == 200) {
console.log(xhr.responseText);
}
};
关于javascript - 如何从 .js 获取 javascript 代码作为文本插入到 html 页面中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48606813/