我有一个带有装饰器的 ES6 类。它有一个静态方法 foo。但是,当我尝试访问静态方法时,它是未定义的。
@withStyles(styles)
class MyComponent extends Component {
static foo(){
return "FOO";
}
render(){
var x = MyComponent.foo; // x=undefined
}
}
当我删除装饰器时,我可以访问静态方法。它不再是未定义的。
class MyComponent extends Component {
static foo(){
return "FOO";
}
render(){
var x = MyComponent.foo; // x=foo()
}
}
这个问题有解决方法吗?