我有在示例中找到的这段代码,所有内容都在快捷方式中:
async function test1(){
const p = await new Promise(resolve => setTimeout(resolve, 2000)).then(()=>'test1');
console.log('Completed test1');
return p;
}
我想删除setTimeout而不是将其设置为非快捷方式,因此我可以向其中添加多个命令并执行其他操作,除了超时...
例如:
async function test1(){
const p = await new Promise(resolve => setTimeout(resolve) => {
// line here
// another one etc
}
如何更改上面的代码?
GCT1015
相关分类