報錯:handlers[i] is not a function
為什么提示報錯呢?
on:function(type,handler){
var bb = this.handlers[type];
if (typeof this.handlers[type] == "undefined") {
this.handlers[type]=[];
}
this.handlers[type].push(handler);
// 實現連綴語法
return this;
},
fire:function(type,data){
var aa = this.handlers[type];
if(this.handlers[type] instanceof Array){
var handlers = this.handlers[type];
for(var i=0,len=handlers.length;i<len;i++){
handlers[i](data);
}
}
}
2016-07-10
有沒有更完整的代碼,你的fire在哪里觸發的,還有你調用組件的代碼呢,發來看一下?