我似乎无法在子类的已定义属性上设置值。
export class Parent {
protected a: number = null;
constructor(){
this.init();
}
init(){
this.a = 1;
}
}
import {Parent} from './Parent';
export class Child extends Parent {
protected b: number = null;
init(){
this.a = 1;
this.b = 2;
}
getB(){
return [this.a, this.b];
}
}
import {Child} from './Child';
var c = new Child();
console.log(c.getB());
getB()
返回[1, null]
,为什么不设置该值?