this.$http.post(global.domain + '/goodsRecord/export',{
                  keyword:this.goodsName,
                  supplier_id:this.supplier_id,
                  condition:this.condition,
                  sort:this.sort,
                },{responseType: 'arraybuffer'}).then((res) => {
                  let fileName = '商品上架总览.xls'
                  let blob = new Blob([res.data], { type: 'application/x-xls' })
                    if (window.navigator.msSaveOrOpenBlob) {
                      navigator.msSaveBlob(blob, fileName);
                    } else {
                      var link = document.createElement('a');
                      link.href = window.URL.createObjectURL(blob);
                      link.download = fileName;
                      link.click();
                      window.URL.revokeObjectURL(link.href);
                    }
              })

一定要记得加axios的第三个参数哦

{responseType: 'arraybuffer'} //{responseType: 'blob'}也行哦

不然就会乱码

Logo

前往低代码交流专区

更多推荐