记:将下载资源转为预览链接的代码

46 阅读1分钟
import axios from 'axios'
const response = await axios({
method: 'get',
url: row.invoiceUrl,
responseType: 'arraybuffer',
})
const blob = new Blob([response.data], {
type: 'application/pdf',
})
url = window.URL.createObjectURL(blob)
window.open(url)