问题
I'm new on stackoverflow and I apologize in advance for any wrong way to ask a question.
回答1:
by 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);
}
};
来源:https://stackoverflow.com/questions/48606813/how-can-i-get-javascript-code-as-text-from-js-to-be-inserted-into-an-html-page