当前位置: 代码迷 >> JavaScript >> 为什么出现 is not a function?解决思路
  详细解决方案

为什么出现 is not a function?解决思路

热度:160   发布时间:2012-05-11 12:55:37.0
为什么出现 is not a function?
function onlineChat(){}
onlineChat.prototype = {
control:null,
chatBox:"#chatContainers",
status:"max",
bar:new chatBar(),
historyBar:new chatBar(),
init:function(){
var o = this;
o.setup(); 
o.bar.barType = "main";
o.bar.maxBtn = "#"+o.control;
o.bar.minBtn = "#chatBoxMin";
o.bar.exitBtn = "#chatBoxExit";

o.bar.historyBar = "history";
o.historyBar.maxBtn = "#chatBoxHistoryBar > input";
o.historyBar.exitBtn = "#chatHistoryBar > input";

o.bar.eventHandler(); // 这里提示eventHandler is not a function()
o.historyBar.eventHandler();
},
  setup:function(){}
}
function chatBar(){} 
chatBar.prototype = {
barType:null,
title:null,
minBtn:null,
maxBtn:null,
exitBtn:null,
eventHandler:function(){alert("aaa");}
}


------解决方案--------------------
好像不会吧,莫非你把chatBar类定义到onlineChat后面了?定义到后面的话就出错。
  相关解决方案