在使用NativeScript实现的接口侦听器中,可以通过以下方式引用'this':
button.on("tap", () => { console.log(this); // 在这里使用'this' });
button.on("tap", function() { console.log(this); // 在这里使用'this' }.bind(this));
这样可以确保在接口侦听器中使用'this'时,它指向正确的对象。
领取专属 10元无门槛券
手把手带您无忧上云