class myClass
{
myPublicMethod(e)
{
console.log(this);
myPrivateMethod(); //does not work
}
#myPrivateMethod()
{
console.log('in myPrivateMethod');
}
}
我已经通过console.log
确认了this
就是myClass
.我得到错误myPrivateMethod is not defined.
如果我try this.myPrivateMethod();
,那么我得到错误myPrivateMethod is not a function.
唯一有效的方法是从myPrivateMethod
中删除#
,公开它并通过this.my(formerly)PrivateMethod();
调用它
是否可以在保持私密的情况下调用此功能?