报错:handlers[i] is not a function

来源:13-1 连缀语法

tlx6550

2016-07-06 15:21

为什么提示报错呢?

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

}

}

}


写回答 关注

1回答

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

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

阿当大话西游之WEB组件

衡量攻城师能力是否成熟的重要指标,本课程会以弹窗组件为例

26365 学习 · 278 问题

查看课程