html:
<el-upload class="upload-demo" :on-change="handleChange" action>
<el-button size="small" type="primary">点击上传</el-button>
</el-upload>
js:
handleChange(input) {
console.log(input, 999);
let file = input;
let reader = new FileReader();
if (typeof reader == "undefined") {
console.log("不支持该功能");
return;
}
let fileName = file.name;
let pointIndex = fileName.lastIndexOf(".");
let fileSuffix = fileName.substr(pointIndex);
if (fileSuffix == ".CSV" || fileSuffix == ".csv") {
try {
reader.readAsText(file.raw, "utf-8");
reader.onload = () => {
//看数据格式里面换行符是什么,依据换行符切割成数