URL.createObjectURL()的使用方法

693 阅读1分钟

背景

处理后端返回的文件流,然后进行下载

方法

URL.createObjectURL()的使用方法

const blob = new Blob([res.data], {
    type: 'application/vnd.ms-excel'
})
const ObjectUrl = window.URL.createObjectURL(blob);
window.location.href = ObjectUrl;