安装3个依赖包
$ npm install -S file-saver
$ npm install -S xlsx
$ npm install -D script-loader
template部分
<template>
<div>
<input
ref="excel-upload-input"
class="excel-upload-input"
type="file"
accept=".xlsx, .xls"
@change="handleClick"
/>
<div
class="drop"
@drop="handleDrop"
@dragover="handleDragover"
@dragenter="handleDragover"
>
拖拽上传文件
<el-button
:loading="loading"
style="margin-left:16px;"
size="mini"
type="primary"
@click="handleUpload"
>点击上传</el-button>
</div>
<el-table
:data="tableData"
border
highlight-current-row
style="width: 100%;margin-top:20px;"
>
<el-table-column v-for="item of tableHeader" :key="item" :prop="item" :label="item" />
</el-table>
</div>
</template>
js部分
<script>
import Vue from 'vue'
import XLSX from 'xlsx'
Vue.use(XLSX)
export de