cyb*_*bat 4 javascript ecmascript-6
我只是将我的一些代码更改为ES6,并且我遇到了一些代码,其中箭头功能不起作用,我不确定我理解为什么.代码来自Hapi的插件来装饰reply界面.
ES5:
server.decorate('reply', 'test', function(schema, response) {
return this.response(mask(schema, response));
});
Run Code Online (Sandbox Code Playgroud)
ES6:
server.decorate('reply', 'test', (schema, response) => {
return this.response(mask(schema, response));
});
Run Code Online (Sandbox Code Playgroud)
E66不起作用并抛出错误:
Uncaught error: this.response is not a function
Run Code Online (Sandbox Code Playgroud)
为什么是这样?