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);
})
}
推荐阅读
- 操作系统|[译]从内部了解现代浏览器(1)
- web网页模板|如此优秀的JS轮播图,写完老师都沉默了
- JavaScript|vue 基于axios封装request接口请求——request.js文件
- vue.js|vue中使用axios封装成request使用
- JavaScript|JavaScript: BOM对象 和 DOM 对象的增删改查
- JavaScript|JavaScript — 初识数组、数组字面量和方法、forEach、数组的遍历
- JavaScript|JavaScript — call()和apply()、Date对象、Math、包装类、字符串的方法
- JavaScript|JavaScript之DOM增删改查(重点)
- javascript|vue使用js-xlsx导出excel,可修改格子样式,例如背景颜色、字体大小、列宽等
- javascript|javascript中的数据类型转换