zoukankan      html  css  js  c++  java
  • vue调接口导出表格

          
     props:{
          form:{
            type:Object,
            default:()=>{}
          },
          indexNum:{
            type:Number,
            default:0
          }
        },
     //导出表格
                handlederive() {
                  let _this=this
                  let data={
                    params:this.form,
                     responseType: 'blob'
                  }
        this.axios.get(this.url,data).then(res=>{
           console.log(res)
             if(res.status == 200){
                 let blob = res.data;
                 const fileReader = new FileReader(); // FileReader 对象允许Web应用程序异步读取存储在用户计算机上的文件的内容
                 fileReader.readAsDataURL(blob); // 开始读取指定的Blob中的内容。一旦完成,result属性中将包含一个data: URL格式的Base64字符串以表示所读取文件的内容
                 fileReader.onload = (event) => { // 处理load事件。该事件在读取操作完成时触发
                 console.log(event)
                     // 新建个下载的a标签,完成后移除。
                     let a = document.createElement('a');
                     let _fileName =_this.list[_this.indexNum]+'.csv';
                     a.download = _fileName;
                     a.href = event.target.result; 
                     document.body.appendChild(a);
                     a.click();
                     document.body.removeChild(a);
                 }
             }
         })
                },
  • 相关阅读:
    Editor REST Client
    log配置
    spring-boot-configuration-processor
    http请求
    做项目用到的一些正则表达式,贴出来共享
    批量插入的实现
    sql执行顺序对比
    Java常用的并发工具类:CountDownLatch、CyclicBarrier、Semaphore、Exchanger
    spring中bean的生命周期
    多属性的对象列表的两种排序方法
  • 原文地址:https://www.cnblogs.com/wangjianping123/p/15249950.html
Copyright © 2011-2022 走看看