javascript|文件导出的get和post方式

get方式(3种写法):
1、window.open("**")是用新窗口打开URL页面
2、location.href="https://www.it610.com/article/**"是用当前页面显示URL

window.open(this.GLOBAL.API_Spm_result+ "completionday/batchId/postId/export?batchId="+this.batchId+"&postId="+this.postId + '&access_token=' + sessionStorage.getItem('cookieaccess_token'))

window.location.href = https://www.it610.com/article/this.GLOBAL.API_ACCOUNT +'users/user/export?deptId=' + exportid + '&access_token=' + sessionStorage.getItem('cookieaccess_token')

download() { //下载 var url = this.GLOBAL.API_ACCOUNT + 'users/download/user' this.loading1 = true//下载中的动画提示 this.$get(url).then(res => { if (res.data.retCode) { alert(res.data.message) } else { window.location.href = https://www.it610.com/article/url +'?access_token=' + sessionStorage.getItem('cookieaccess_token')} this.loading1 = false//下载中的动画提示隐藏 }) },

【javascript|文件导出的get和post方式】post方式(这里有两种方式注释的是一种js-file-download插件是一种的)
outputCompound(){ var url = this.GLOBAL.API_indicator + "indicator/composite/export" var params = { batchId:this.batchId, objectType:"5" } axios.post(url,params,{responseType: 'arraybuffer'}).then((res) => { // if(res.data.retCode){ //alert(res.data.message) // }else{ //let blob = new Blob([res.data], {type: "application/vnd.ms-excel"}); //let objectUrl = URL.createObjectURL(blob); //window.location.href = https://www.it610.com/article/objectUrl; // //} var fileDownload = require('js-file-download') let fileName = "复合指标.csv"; fileDownload(res.data,fileName); }) }


    推荐阅读