atq

导航

 

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");
};

posted on 2024-07-22 08:29  atq  阅读(3)  评论(0编辑  收藏  举报