读书人

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

发布时间: 2012-05-11 12:55:37 作者: rapoo

为什么出现 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后面了?定义到后面的话就出错。

读书人网 >JavaScript

热点推荐