1
下面是我的代碼 -如何導出異步函數?
abc.js
class abc {
async foo1() {
// do something
return result;
}
async foo2() {
// do something
return result;
}
module.exports = abc
}
另一-file.js
const abc = requir(./abc);
abc.foo1();
// this results in error
// TypeError : abc.foo1 is not a function
我應該怎麼辦呢?
'abc'是一類。你需要一個實例。這與async無關。 – SLaks