不确定我的问题用词是否正确。但是基本上我有一个类,但是我想为其编写一个新方法。说我的班级看起来像这样:
class MyClass {
constructor () {
this.someProperty = []
this.someMethod = this.someMethod.bind(this)
}
function someMethod () {
// do something
}
}
现在,因为我没有直接访问此类的权限,所以我将使用prototype
创建一个新方法>
MyClass.prototype.myNewMethod = function (params) { // do something else // how to access someProperty? And to the bind to MyClass? }
但是现在说我想访问
someProperty
,并且也想对此新方法进行bind
。我该怎么办?
事实上,我的方法创建一开始就正确吗?无论如何,我想要它具有对类内部的this
的相同访问权限。我该怎么办?
不确定我的问题用词是否正确。但是基本上我有一个类,但是我想为其编写一个新方法。说我的班级是这样的:class MyClass {Constructor(){this ....
我不知道您想做什么,但是您可以访问它: