以《vue3.0》为例子
import { ExcelExport } from '@/api/locationcontainer' //导出 (接口)
export default defineComponent({
name: 'aa',
setup() {
// 定义一个解析方法
const download = (res, type, filename) => {
// 创建blob对象, 解析流数据
const blob = new Blob([res], {
// 如果后端没有返回下载文件类型,
// 则需要手动设置: type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;chartset=utf-8" 表示下载文档为xlxs, 如果是word文档则设置为"application/msword"
type: type,
})
const a = document.createElement('a')
const URL = window.URL || window.webkitURL
// 根据解析后的blob对象创建URL对象
const herfs