问答详情
源自:13-1 连缀语法

报错:handlers[i] is not a function

为什么提示报错呢?

http://img.mukewang.com/577cb15100018f9607870193.jpg

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);

}

}

}


提问者:tlx6550 2016-07-06 15:21

个回答

  • 小小撼大树
    2016-07-10 16:59:53

    有没有更完整的代码,你的fire在哪里触发的,还有你调用组件的代码呢,发来看一下?