前端下载的优雅实现
下面展示一些 内联代码片
。
/**下载 */
handleDownLoad(row) {
let url = `${process.env.VUE_APP_BASE_URL}/common/download/${row.fileId}`//设置下载路径
const link = document.createElement('a')
link.style.display = 'none'
link.href = url
link.setAttribute('download', `${row.fileName}.${row.extName}`)
document.body.appendChild(link)
link.click()
document.body.removeChild(link)
// window.open(`${process.env.VUE_APP_BASE_URL}/common/download/${row.fileId}`);
},