zoukankan      html  css  js  c++  java
  • vue 下载文件

    需求: 一个可以下载的接口,前端做出导出功能     接口:  https://www.cnblogs.com/kaibindirver/p/15470706.html

     方法一:

    axios请求参数要加上       参考: https://www.cnblogs.com/kaibindirver/p/15396789.html 

    responseType: 'arraybuffer'
     
     
    调用时加上红色的代码
    async down2(){
            let { response } = await rzCheck02(`fortime=${this.time1}&query=${this.selctaction}&totime=${this.time2}&index=2`);
            const objectUrl = window.URL.createObjectURL(new Blob([response], {type: "application/vnd.ms-excel"}));
            const a = document.createElement('a');
            a.href = objectUrl;
            a.download = '2023.xls';
            a.click();
            a.remove();
    },

    方法二:

    用open可行,单交互是会再起一个标签页下载

    async down(){
    // window的方法可行
    window.open(`/v2/tool/check?fortime=${this.time1}&query=${this.selctaction}&totime=${this.time2}&index=2&type=${this.type}&page=4000`)
    },
  • 相关阅读:
    .net面试题目问答题2
    .net面试题目问答题1
    .net面试题目101-130
    .net面试题目51-100
    .net面试题目1-50
    试题
    2014奇虎360研发类校园招聘面试题分享
    JAVA基础
    JAVA中集合的继承关系
    美团
  • 原文地址:https://www.cnblogs.com/kaibindirver/p/15797386.html
Copyright © 2011-2022 走看看