Such a class:
class TestClass {
name = 'abc'; //直接声明在class中
static staticValue = 456; //这是静态属性
showName() {
console.log(this.name);
}
}
let cls = new TestClass();
cls.showName();
Is the above syntax supported in es? How to configure it if babel is used for translation?
Static attributes should be remembered as an ES7 proposal.
It seems that babel-stage2 will work. I don’t remember it clearly. You’ll know if you try it.