js文件下载(axios)

第一步

npm install js-file-download

第二步

import fileDownload from 'js-file-download'
 
axios.get(`/operation/ruleImport/template`, {
        responseType: 'blob' //返回的数据类型
    })
    .then(res => {
        fileDownload(res.data, this.fileName)//this.fileName你需要的文件名,要带后缀
    })


你可能感兴趣的:(javascript,前端,vue.js)