2015-02-12 53 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)。