在js高级程序设计书上,控制台上出现Uncaught ReferenceError: bind is 财富值70

2016-11-03 03:22发布

var EventUtil = {     addHandler:function(element,type,handler){         if(element.addEventListener){             element.addEventListener(type,handler,false);         }else if(element.attachEvent){             element.attachEvent("on"+type,handler);         }else{             element["on"+type] = handler;         }     },     removeHandler:function(element,type,handler){         if(element.removeEventListener){             element.removeEventListener(type,handler,false);         }else if(element.detachEvent){             element.detachEvent("on"+type,handler);         }else{             element["on"+type] = null;         }     } }; var handler={     message:"Event handled",     handleClick:function(event){         alert(this.message);     } }; var btn=document.getElementById("btn"); EventUtil.adddHandler(btn,"click",bind(handler.handleClick,handler));
1条回答
mishen - whatsns产品经理
2016-11-03 03:15 .采纳回答

最后一行bind函数没有定义

一周热门 更多>