vue-下载本地项目中的文件 文件放在public下 新建了一个文件夹statics
import axios from 'axios' downs(name) { axios.get('statics/' + name, { //静态资源文件夹public responseType: 'blob', }).then(response => { const url = window.URL.createObjectURL(new Blob([response.data])); const link = document.createElement('a'); let fname = name; link.href = url; link.setAttribute('download', fname); document.body.appendChild(link); link.click(); }).catch(error => { console.log('error:' + JSON.stringify(error)) }); }
标签:文件,axios,name,vue,link,本地,error,下载 From: https://www.cnblogs.com/lzzc/p/17349412.html