<el-upload action="http://192.168.1.78:8079/weeg-common-base/commonFile/upload" :show-file-list="false"
:before-upload="beforeUpload" accept=".xls,.xlsx">
<el-button size="small">
上传文件
<i class="el-icon-upload el-icon--right"></i>
</el-button>
</el-upload>
import XLSX from "xlsx"
beforeUpload(file){
let fr = new FileReader()
fr.onloadend = (e)=>{
let data = e.target.result
let workbook = XLSX.read(data,{
type:'binary'
})
let xlsName = workbook.SheetNames[0] //sheet1
let jsonData = XLSX.utils.sheet_to_json(workbook.Sheets[xlsName])
console.log(jsonData)
}
fr.onerror = (err)=>{
console.log(err)
}
fr.readAsBinaryString(file)
},