需求:前端导入xlsx表格,并解析成table数据传参给二级页面
最后解决代码:
导入插件: npm install xlsx --save
this.$toast({})是封装的信息弹窗组件
<el-upload
ref="upload"
action="https://jsonplaceholder.typicode.com/posts/"
:auto-upload="false"
:show-file-list="false"
:limit="1"
accept=".xls,.xlsx"
:on-change="changeHandle">
<div class="button purpleMinor">批量分配</div>
</el-upload>
<script>
var XLSX = require("xlsx")
changeHandle(file,fileList) {
this.$refs.upload.clearFiles() // 上传成功之后清除历史记录
console.log(file,'file')
console.log(fileList,'fileList')
let type = fil