function load(name) {let xhr = new XMLHttpRequest(),okStatus = document.location.protocol === "file:" ? 0 : 200;xhr.open('GET', name, false);xhr.overrideMimeType("text/html;charset=utf-8");//默认为utf-8xhr.send(null);return xhr.status === okStatus ? xhr.responseText : null;}let text = load("./lic.txt");
转载 添加链接描述
https://blog.csdn.net/qq_39110538/article/details/83098474