老師的代碼是不是要加一句?
// 老師的代碼是不是要加一句?:
on: function(type,handler){
if(this.handlers[type]==='undefined'){
? this.handlers[type]=[]
?//這是多加的一句,不然綁定多個名稱相同的事件時總是少一個
?this.handlers[type].push(handler)
}else{
?
?this.handlers[type].push(handler)
} }
// 老師的代碼是不是要加一句?:
on: function(type,handler){
if(this.handlers[type]==='undefined'){
? this.handlers[type]=[]
?//這是多加的一句,不然綁定多個名稱相同的事件時總是少一個
?this.handlers[type].push(handler)
}else{
?
?this.handlers[type].push(handler)
} }
2018-09-28
舉報
2018-11-26
on是綁定自定義事件,無論要綁定的事件是否定義過,this.handlers[type].push(handler)是必須的