vue 从服务端导出表格文件

 //导出接口采用axios,发送请求时响应类型改为'blob'类型
 axios({
     
    method: 'post',
    responseType: 'blob' ,
    url,
    data,
    headers: {
      'Content-Type': 'application/json' }
    })
 	
 //导出数据
      advanceExcelFile() {
     
       
        exportMemberList({
     
          
        }).then(res => {
     
          const url = window.URL.createObjectURL(new Blob([res], {
     type: 'application/octet-stream'}))
          console.log(url, url)
          const link = document.createElement('a')
          link.style.display = 'none'
          link.href = url
          link.setAttribute('download', '员工信息.xls')
          document.body.appendChild(link)
          link.click()
          this.$Message.success('导出成功')
        }).catch(res => {
     
          // this.loading = false;
        })
      },

你可能感兴趣的:(html)