Vue 导出Excel 后端返回地址

导出使用 location.href = ’ url '; 此方法不仅可以导出Excel …

//导出Excel
exportExcel() {
    
    
    this.$axios.get("接口地址",{
    
    params:{
    
    
            参数1: data ...
        }}).then(res => {
    
    
        if(res.request.status === 200) {
    
    
        	// 导出 
            location.href = res.request.responseURL;
            // window.open(res.request.responseURL);
            this.$message({
    
    message: '导出成功', type: 'success'});
        }
    }).catch( err => {
    
    
        this.$message.error('导出失败');
    })
},

猜你喜欢

转载自blog.csdn.net/weixin_44640323/article/details/108756402