Vue.prototype.$await = async function(action) { try { await action(); } catch (err) { // 这里是你处理错误的逻辑 console.log("Cought Error: ", err); }};doSomething(...args) { this.$await(async () => { await asyncDealWith(...args); });}
本文共 320 字,大约阅读时间需要 1 分钟。
Vue.prototype.$await = async function(action) { try { await action(); } catch (err) { // 这里是你处理错误的逻辑 console.log("Cought Error: ", err); }};doSomething(...args) { this.$await(async () => { await asyncDealWith(...args); });}
转载于:https://www.cnblogs.com/chris-oil/p/10700943.html