Class Demo{
const _fun1 = Symbol('_fun1');
const _fun2 = Symbol('_fun2');
[_fun1] = function() {
console.log("_fun1");
}
[_fun2] = function() {
console.log("_fun2");
}
test(){
this_fun1;
this_fun2;
}
}
let demo = new Demo();
demo.test();
问题:会报_fun2没有找到。
解决:需要加分号结束_fun1定义。
[_fun1] = function() {
console.log("_fun1");
};