0
我试图创建一个生成新实例的静态函数。该实例属于静态函数所属的类。es6从静态函数获取对类构造函数的访问
下面是一个例子
class A {
static getInstance() {
return new A();
}
}
到目前为止好let a = A.getInstance();
将正常工作。
我想在children类中继承这个功能。
class B extends A {}
let b = B.getInstance(); // This will return an instance of A.
我想B.getInstance()
返回B.
'的getInstance(){返回新本; }' – Keith