vue 读取本地.txt文件

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); //打印文件信息
            },
        }

  

posted @ 2021-02-22 17:44  搜戴斯  阅读(11633)  评论(0编辑  收藏  举报