使用axios 的post请求下载文件,

axios({
    method: 'post',
    data: param,
    responseType:'blob',
    url: _urls + '/Downloaddata'
}).then(data=>{
    var  blob = new Blob([data.data], 
        {type: "application/vnd.ms -excel"}
    );
    var url = window.URL.createObjectURL(blob);
    window.location.href = url;
})

  完成,后台记得返回文件时 把文件转成blob格式,ie暂时不能用

posted @ 2019-01-23 16:51  qkstart  阅读(2838)  评论(0编辑  收藏  举报