我有一个Javascript类someClass的方法someFunc 在方法定义内的btn变量的onclick处理程序中,我希望获得对SomeClass和按钮的引用。); this.somePropertyOfSomeClass = true; //this works, because bindthis.classList.add("active"); //this does not
为了进一步在适当的Javascript中进行实验,我尝试从一个方法(SayHello)运行另一个方法(WaitAndSayHello)。因为涉及到回调,所以我使用了来确保每个方法中的“this”都引用该对象。console.log(this) }, 500); this.WaitAndSayHello.bind(this); // This bi