<分区>
我很惊讶这不起作用。 (我正在运行带有 --harmony_arrow_functions
标志的 iojs
2.3.0。)
class Foo {
constructor() { this.foo = "foo"; }
sayHi() { return (() => this.foo)(); }
}
f = new Foo();
f.sayHi // Cannot read property 'foo' of undefined.
我本以为箭头函数会为 this
获取正确的值。我错过了什么吗?