mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/learning-system-portal.git
synced 2025-12-11 03:46:44 +08:00
U币的导出问题处理
This commit is contained in:
@@ -2,8 +2,8 @@
|
|||||||
<div class="u-currency">
|
<div class="u-currency">
|
||||||
<div class="myubi">
|
<div class="myubi">
|
||||||
<div class="ubi-hear">
|
<div class="ubi-hear">
|
||||||
|
|
||||||
<h6>我的U币:{{uinfo.uCurrency}}</h6><span class="pointer" @click="dialogVisible = true">U币规则
|
<h6>我的U币:{{uinfo.uCurrency}}</h6><span class="pointer" @click="dialogVisible = true">U币规则
|
||||||
<i class="el-icon-arrow-right"></i> </span>
|
<i class="el-icon-arrow-right"></i> </span>
|
||||||
<el-button icon="el-icon-document" @click="exportRecord()">导出记录</el-button>
|
<el-button icon="el-icon-document" @click="exportRecord()">导出记录</el-button>
|
||||||
</div>
|
</div>
|
||||||
@@ -363,32 +363,24 @@
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
exportRecord() {
|
exportRecord() {
|
||||||
|
|
||||||
let downUrl='';
|
let downUrl='';
|
||||||
|
|
||||||
let curHost=window.location.host;
|
// let curHost=window.location.host;
|
||||||
console.log(window.location.host,'window.location.host');
|
// console.log(window.location.host,'window.location.host');
|
||||||
// if(curHost=='localhost' || curHost='127.0.0.1'){
|
// if(curHost=='localhost' || curHost='127.0.0.1'){
|
||||||
// downUrl=process.env.VUE_APP_BOE_WEB_URL+process.env.VUE_APP_CESOURCE_BASE_API+'/xboe/m/stat/usercoinrecord/export?aid=' + this.userInfo.aid;
|
// downUrl=process.env.VUE_APP_BOE_WEB_URL+process.env.VUE_APP_CESOURCE_BASE_API+'/xboe/m/stat/usercoinrecord/export?aid=' + this.userInfo.aid;
|
||||||
// }else{
|
// }else{
|
||||||
// //let urlPre = window.location.protocol + '//' + window.location.host;
|
// //let urlPre = window.location.protocol + '//' + window.location.host;
|
||||||
// downUrl=process.env.VUE_APP_CESOURCE_BASE_API+'/xboe/m/stat/usercoinrecord/export?aid=' + this.userInfo.aid;
|
// downUrl=process.env.VUE_APP_CESOURCE_BASE_API+'/xboe/m/stat/usercoinrecord/export?aid=' + this.userInfo.aid;
|
||||||
// }
|
// }
|
||||||
|
downUrl=process.env.VUE_APP_STAT_BASE_API+'/xboe/m/stat/usercoinrecord/export?aid=' + this.userInfo.aid;
|
||||||
downUrl=process.env.VUE_APP_BOE_WEB_URL+process.env.VUE_APP_CESOURCE_BASE_API+'/xboe/m/stat/usercoinrecord/export?aid=' + this.userInfo.aid;
|
|
||||||
|
|
||||||
const el = document.createElement('a');
|
const el = document.createElement('a');
|
||||||
el.style.display = 'none';
|
el.style.display = 'none';
|
||||||
el.setAttribute('target', '_blank');
|
el.setAttribute('target', '_blank');
|
||||||
/**
|
|
||||||
* download的属性是HTML5新增的属性
|
|
||||||
* href属性的地址必须是非跨域的地址,如果引用的是第三方的网站或者说是前后端分离的项目(调用后台的接口),这时download就会不起作用。
|
|
||||||
* 此时,如果是下载浏览器无法解析的文件,例如.exe,.xlsx..那么浏览器会自动下载,但是如果使用浏览器可以解析的文件,比如.txt,.png,.pdf....浏览器就会采取预览模式
|
|
||||||
* 所以,对于.txt,.png,.pdf等的预览功能我们就可以直接不设置download属性(前提是后端响应头的Content-Type: application/octet-stream,如果为application/pdf浏览器则会判断文件为 pdf ,自动执行预览的策略)
|
|
||||||
*/
|
|
||||||
el.setAttribute('download', '我的U币记录');
|
el.setAttribute('download', '我的U币记录');
|
||||||
el.href = downUrl;
|
el.href = downUrl;
|
||||||
console.log(el);
|
|
||||||
document.body.appendChild(el);
|
document.body.appendChild(el);
|
||||||
el.click();
|
el.click();
|
||||||
document.body.removeChild(el);
|
document.body.removeChild(el);
|
||||||
|
|||||||
Reference in New Issue
Block a user