moneyExport:Debounce(function () { axios .post("{{ url('/bus/getExportToken') }}",{type:1}) .then((res) =>{ if(res.data.status_code===1){ let getToken = res.data.data.token // 创建 <a> 标签 var link = document.createElement("a"); // 设置链接地址和文本内容 link.href = `{{ url('/bus/moneyExport') }}?type=1&&begin_time=${this.form.begin_time}&&end_time=${this.form.end_time}&×tamp=${getToken}`; link.target = "_blank"; link.innerHTML = " "; // 将<a>元素添加到文档中 document.body.appendChild(link); // 模拟点击<a>元素 link.click(); document.body.removeChild(link); // 释放标签 }else if(res.data.status_code===403){ this.$toast(res.data.message) window.location.href = '/ding'; }else{ this.$toast(res.data.message) } }) .catch((error)=>{ // 请求失败处理 console.log(error); this.$toast("联网异常") }); }, 300),用异步写
时间: 2024-04-02 21:34:16 浏览: 133
sw_debounce.zip_VHDL/FPGA/Verilog_Verilog_
async function moneyExport() {
try {
const response = await axios.post("{{ url('/bus/getExportToken') }}", { type: 1 });
if (response.data.status_code === 1) {
let getToken = response.data.data.token;
// 创建 <a> 标签
var link = document.createElement("a");
// 设置链接地址和文本内容
link.href = `{{ url('/bus/moneyExport') }}?type=1&&begin_time=${this.form.begin_time}&&end_time=${this.form.end_time}&×tamp=${getToken}`;
link.target = "_blank";
link.innerHTML = " ";
// 将<a>元素添加到文档中
document.body.appendChild(link);
// 模拟点击<a>元素
link.click();
document.body.removeChild(link); // 释放标签
} else if (response.data.status_code === 403) {
this.$toast(response.data.message);
window.location.href = "/ding";
} else {
this.$toast(response.data.message);
}
} catch (error) {
console.log(error);
this.$toast("联网异常");
}
}
const debouncedMoneyExport = Debounce(moneyExport, 300);
阅读全文