一直忘,特此记下大致思路。


exportTable () {
      const origin = window.location.origin;
      const id = this.$route.params.id;
      window.open(`${origin}/pyxis-dict/api/dict/downLoadDict? 
      id=${id}`, '_self');
},

 

在 assets 等文件夹放置文件点击下载提示未找到文件的解决办法:

将要下载文件放到public 下面,a标签下载是相对于public

// 下载模板
    private downloadTemplate() {
        const url = './template/cartImport.xlsx';
        const name = 'cartImport.xlsx';
        var nowA =document.createElement('a');
        nowA.setAttribute('href',url);
        nowA.setAttribute('download',name);
        nowA.style.display= 'none';
        document.body.appendChild(nowA);
        nowA.click();
        document.body.removeChild(nowA);
    }
 

相关文章:

  • 2022-12-23
  • 2021-11-10
  • 2022-01-05
  • 2021-12-26
  • 2022-12-23
  • 2021-05-14
  • 2021-09-15
  • 2021-11-18
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-11
  • 2021-04-14
相关资源
相似解决方案