从Typescript中的类实例调用静态函数



如何从实例化的类变量中调用静态函数?

示例:

class Foo {
static Bar() {
console.log("Bar");
}
}
let i = new Foo();
i.Bar() // Not working
// Something like this?
i.toClass().Bar();

由于Bar是静态的,所以您可以简单地用类名Foo 来调用它

Foo.Bar();

最新更新