报错: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);
}
}
}