2015-02-12 89 views
-1

当我尝试从其他函数调用方法时,出现上述错误。 有人可以帮忙!TypeError:status.set不是函数Javascript

方法:

 function Status() { 

    var self = this; 

    self.set = function(text) { 
    var index; 

    while (self.lblStatus.childNodes.length > 0) { 
     self.lblStatus.removeChild(self.lblStatus.childNodes.item(0)); 
    } 
    self.lblStatus.appendChild(document.createTextNode(text)); 
    } 
    } 

,并在其他函数的调用是

status.set(language.STATUS_CONTACTING_SERVER); 

的错误:

TypeError: status.set is not a function

能有人帮助,请找出什么是错的与th在!

感谢ü

+0

当你试图调用'set'时,'console.log(status.set)'的输出是你期望的吗?你有没有你试图调用这个方法的代码? – jdphenix 2015-02-12 05:28:22

+0

我试图调用该方法的代码 函数Identify(){var self = this; self.doIdentification = function(event){ logon.setEnabled(self.txtUsername,false); status.set(language.STATUS_CONTACTING_SERVER); – kemyjames 2015-02-12 05:32:00

+0

在控制台我只是得到那个错误TypeError:status.set不是一个函数 – kemyjames 2015-02-12 05:35:16

回答

0

这听起来像你不实例化类...

凡在你的代码你有:

var status = new Status(); 

另外,从您发布的信息中可以看出,缺少的属性等(lblStatus)。