js文件下载

if (response.status == 200) {
this.$message.success("下载成功!");
const blob = new Blob([response.data], {
type: "application/msword"
});
const downloadElement = document.createElement('a')
const href = window.URL.createObjectURL(blob);
downloadElement.href = href
downloadElement.download = con.name + '.doc'
document.body.appendChild(downloadElement)
downloadElement.click()
document.body.removeChild(downloadElement)
window.URL.revokeObjectURL(href)
console.log(response.data.data)
} else {
this.$message.error("下载文件异常!");
}
posted on 2022-01-03 17:00  巨星太空易  阅读(129)  评论(0)    收藏  举报