一、安装xlsx
npm install xlsx
二、引入xlsx
import XLSX from 'xlsx'
三、模板
class="import hidden-xs-only"
ref="upload"
action="/"
:show-file-list="false"
:on-change="importExcel"
:auto-upload="false"
>
导入Excel表格
四、导入方法
//导入
importExcel(file) {
// let file = file.files[0] // 使用传统的input方法需要加上这一步
const types = file.name.split('.')[1]
const fileType = ['xlsx','xls'].some((item) => item === types)
if (!fileType) {
this.$message('格式错误!请下载词库导入模板编辑后上传')
return false
}
this.file2Xce(file).then((tabJson) => {
if (tabJson && tabJson.length > 0) {