String复杂情况,多个同字符替换
replaceAll(str, searchValue, replaceValue) {
return str.replace(new RegExp(searchValue,"gm"),replaceValue);
},
- str:需要替换的字符串
- searchValue:需要替换的字符
- replaceValue:要替换的字符
点击下载获取下载链接创建<a>标签下载
async btnExport(url) {
let that = this;
this.loading = true;
let a = document.createElement('a');//创建a标签
a.href = url;//文件url
document.body.appendChild(a);
a.click();//触发下载
document.body.removeChild(a);
setTimeout(async () => {
that.loading = false;
}, 4000);//4s后关闭loading,可以根据情况增减
},
- url:异步请求获取的链接地址
后续持续更新...