为什么异步函数会没效果呢?谁知道哦?
@click触发methods中的事件:
以下是结果
为什么异步函数会没效果呢?谁知道哦?
@click触发methods中的事件:
以下是结果
setTimeout 包进Promise 试试吧。
function delay(fn,time){return new Promise(resolve=>{setTimeout(()=>{resolve(fn())},time)})}
function fun1() { console.log(1)}
async function test(){ await delay(fun1,500);console.log(2)}
test();//测试一下
//输出 1,2