Javascript 无法在重写的异步方法中使用super.method()
我想在将请求委托给父方法之前和之后执行一些任务。并且Javascript 无法在重写的异步方法中使用super.method(),javascript,async-await,babeljs,Javascript,Async Await,Babeljs,我想在将请求委托给父方法之前和之后执行一些任务。并且Parent.create被实现为一个async函数。因此,执行以下操作会导致错误 async create(ctx, next) { await super.create(ctx, next); //'super' keyword unexpected here } 但这是可行的 create(ctx, next) { super.create(ctx, next); //wait for the promise, then
Parent.create
被实现为一个async
函数。因此,执行以下操作会导致错误
async create(ctx, next) {
await super.create(ctx, next); //'super' keyword unexpected here
}
但这是可行的
create(ctx, next) {
super.create(ctx, next); //wait for the promise, then
}
所有父方法都绑定到this
,因为我在用作路由器处理程序时需要类上下文
如何在
async
函数中使用super。这是哪种环境?浏览器(哪个)?节点?巴别塔?使用巴别塔寄存器
。这似乎是一个公开问题。必须使用transform-es2015-classes
才能工作。谢谢