美文网首页
post方式下载

post方式下载

作者: 家有饿犬和聋猫 | 来源:发表于2020-09-27 14:36 被阅读0次

    // 采集能耗下载
    export function collectRecordDown (reqData) {
    axios.post('/api/v1.0/energy/collect/record/down', reqData, {
    headers: { 'Content-Type': 'application/json' },
    responseType: 'blob'
    }).then(res => {
    let blob = res.data;
    let {headers} = res;
    let Headers = headers['content-disposition'].split('=');
    const fileName = decodeURI(${Headers[1]});
    if ('download' in document.createElement('a')) { // 非IE下载
    const elink = document.createElement('a');
    elink.download = fileName;
    elink.style.display = 'none';
    elink.href = window.URL.createObjectURL(blob);
    document.body.appendChild(elink);
    elink.click();
    URL.revokeObjectURL(elink.href); // 释放URL 对象
    document.body.removeChild(elink);
    } else { // IE10+下载
    navigator.msSaveBlob(blob, fileName);
    }
    });
    }

    相关文章

      网友评论

          本文标题:post方式下载

          本文链接:https://www.haomeiwen.com/subject/jlfluktx.html