参考链接:
https://blog.csdn.net/userkang/article/details/90144101
https://juejin.im/post/5c2dc7a9e51d4573c8491e77
let timeout = null; //防抖 const debounce = function (fn, wait) { if (timeout !== null) clearTimeout(timeout); timeout = setTimeout(fn, wait); }; // async/await处理异常事件 const to = function (promise) { return promise .then((data) => { return [null, data]; }) .catch((err) => [err]); }; export default { debounce, to, };