参考方法:https://blog.csdn.net/qq_43138078/article/details/90044628
事前一定要看过这篇:VUE批量导入/读取excel、下载模板文件功能实现
在选择文件的时候判断:插在importFile(file)方法中
else if(this.suffix === "txt" ){
console.log("选择的是txt",file,objFile);
// const objFile = file.target.files[0];//在VUE不使用这个
const reader = new FileReader();
reader.onload = objFile => this.$emit("load", this.dealNum(objFile.target.result));
reader.readAsText(objFile);
}
单独写个方法,因为上面用到dealNum这个方法
dealNum(item){
let word = item.replace(/\n|\r\n/g,"<br/>")