网页文件下载方法

function download(data, ) {
    if (!data) {
        return
    }
    let url = window.URL.createObjectURL(new Blob([data]))
    let link = document.createElement('a')
    link.style.display = 'none'
    link.href = url
    link.setAttribute('download', 'excel.xlsx')
    document.body.appendChild(link)
    link.click()
}

推荐阅读更多精彩内容