需要实现一个下载csv文件的功能,但后台没有对这个下载文件进行处理,而是将csv数据传给前台而已,需要前台做一下处理。 ? custom-confirm" @click="downloadByPeople()" type="primary">下载执行人工时表</el-button> 通过异步请求获得的后台json返回数据是这样的格式 只需要以下步骤就可以实现纯vue.js下载csv文件的功能: 1 downloadByPeople(){ 3 this. = this.genUrl(res.data.data.workhour_csv_data, {});//{}指的是表头,res.data.data.workhour_csv_data是后台返回来的数据 const a = document.createElement('a'); 6 a.href = url; 7 a.download = "工时统计文件.csv