vue 讀取本地.txt文件
methods: {
getdev() {
// 更新數據devInfo.txt文件接口
let xhr = new XMLHttpRequest(),
okStatus = document.location.protocol === "file:" ? 0 : 200;
xhr.open('GET', '../../../devInfo.txt', false);// 文件路徑
xhr.overrideMimeType("text/html;charset=utf-8");//默認為utf-8
xhr.send(null);
console.log(xhr.responseText); //打印文件信息
},
}
