js 常用创建a标签实现下载功能

downExcelTem = () => {
    let url = `${config.API_ROOT}/excelTemplateExport`
    let link = document.createElement('a')
    link.style.display = 'none'
    link.href = url 
    link.setAttribute('download', 'sample.xlsx')
    document.body.appendChild(link)
    link.click()
  }

  

posted @ 2021-12-03 10:52  _心之所向便是光  阅读(1067)  评论(0编辑  收藏  举报