1 downloadByPeople(){
3 this.$http.FileGet(this.pageParams).then(res => {
4 const url = this.genUrl(res.data.data.workhour_csv_data,{});//{}指的是表头,res.data.data.workhour_csv_data是后台返回来的数据
5 const a = document.createElement('a');
6 a.href = url;
7 a.download = "工时统计文件.csv";
8 a.click();
9 window.URL.revokeObjectURL(url);
10 });
11 },
1 genUrl(encoded,options) {
2 const dataBlob = new Blob([`\ufeff${encoded}`],{ type: 'text/plain;charset=utf-8' });//返回的格式
3 return window.URL.createObjectURL(dataBlob);
4 },