I持っているこれら二つの活字体のクラス:活字体オーバーライドされたクラスのメソッドと、この
class Base {
value: string;
lambdaExample =() => {
this.value = 'one';
}
methodExample() {
this.value = 'two';
}
}
class Child extends Base {
lambdaExample =() => {
super.lambdaExample(); // Error, because I've overwritten (instead of overridden) the method
this.value = 'three'; // ok
}
methodExample() => {
super.methodExample(); // ok
this.value = 'four'; // Error: this refers to window, not to the actual this
}
}
どのように私はthis
参照がと私はメソッドをオーバーライドしてからそれらを呼び出すことができ、信頼性があるように私の方法を記述します親クラス?
[スーパークラスからオーバーライドされたメソッドをtypescriptで呼び出す]の可能な複製(http://stackoverflow.com/questions/30819663/call-an-overridden-method-from-super-class-in-typescript) – smnbbrv
重複ではない:その質問は、クラスプロパティを使ってオーバーライドされたメソッドについてではなく、コンストラクタでクラスメソッドを呼び出すことに関するものです。 – Jorn
@smnbbrvこの質問は、この問題とは関係ありません。 –