【发布时间】:2018-07-22 03:43:45
【问题描述】:
我正在使用 ES6:
class Parent {
static sayHello(){
ChildN.sayHi()
}
}
class ChildOne extends Parent {
static sayHi(){
console.log('hi from ChildOne')
}
}
class ChildTwo extends Parent {
static sayHi(){
console.log('hi from ChildTwo')
}
}
ChildOne.sayHello()
ChildTwo.sayHello()
我想要 N 个孩子。是否可以在父类中动态获取子类并调用其静态方法?也就是说,如何在父类中泛化 ChildN?
【问题讨论】:
标签: javascript node.js static