// 重要代码
<el-upload
:show-file-list="false"
:auto-upload="false"
:limit="1"
:on-change="handleChangeFile"
:file-list="fileList"
class="upload-demo"
action="#"
accept=".xlsx, .xls"
>
<el-button type="primary" size="medium" icon="el-icon-circle-plus-outline">
上传
</el-button>
</el-upload>
// 实现预览excel
<vue-office-excel :src="url" class="excel-box" />
<script>
import VueOfficeExcel from '@vue-office/excel'
export default {
components: {
VueOfficeExcel
},
methods: {
// 预览文件
handleChangeFile(file) {
this.file = file.raw
const blob = new Blob([file.raw])
this.url = window.URL.createObjectURL(blob)
this.showExcel = true
},
}
}
</script>
el-upload返回的文件预览excel
最新推荐文章于 2024-06-30 04:24:37 发布