文件读取~~~
表格数据
excel读取数据.jpg
// template
// 文件选择,或者使用原生 imput type 为 file
action="/"
:on-change='onChange'
:auto-upload='false'
:show-file-list="false"
accept=".xls, .xlsx"
>
选择文件
{
{ fileData.name }}
// js
data() {
return {
outputs: [], // 保存读取出来的数据
fileData:'', // 保存选择的文件
};
},
methods: {
// 文件选择回调
onChange(file,fileList){
this.fileData = file // 保存当前选择文件
this.readExcel() // 调用读取数据的方法
},
// 读取数据
readExcel(e) {
let that = this;
const files = that.fileData;
console.log(files);
if