這個????將實例方法用作事件處理程序的回調(diào),將更改this從…“我的例子”到“不管是什么叫回調(diào)”..所以我的代碼是這樣的function MyObject() {
this.doSomething = function() {
...
}
var self = this
$('#foobar').bind('click', function(){
self.doSomethng()
// this.doSomething() would not work here
})}這是可行的,但這是最好的方法嗎?我覺得很奇怪。
這個????
瀟湘沐
2019-06-29 17:34:44