2012-01-23 3 views
0

NodeJS와 비슷한 Bonji를 사용합니다. Firefox js 엔진을 기반으로합니다. 기본적으로이 오류가 발생합니다. 나는 아래의 .Get 함수에서 "this"를 참조하고 있습니다.this._get은 함수가 아닙니다. javascript oop 및 프로토 타입

기본적으로 SFtpClient라는 도구가 있습니다. 폴더의 내용을 나열하는 "Get"메서드가 있지만 include 파일의 드롭으로이 프로토 타입을 변경하려고합니다. 그것을 변경해야합니다. a/실패 할 때 여러 번 재 시도하고 b/it에는 재귀 폴더 목록 기능이 있습니다.

그래서 프로토 타입을 사용하여 이동했습니다. 이동. 게타. 나는 아래의 코드를 실행할 때

Jan 23 04:51:34 beta bondi: === this._Get is not a function --- Prio(6) Result(0x0) File(/home/nwo/approot/include/sftpclientenh 

: 나는 오류가있을 이유

은 사람이 볼 수 있을까요? 감사

SFtpClient.prototype._Get = SFtpClient.prototype.Get; 
SFtpClient.prototype.Get = function(Folder, Retries){ 

    //defaults 
    if(!Retries) Retries = 5; 
    if(!Folder) Folder = "~/"; 

    //vars 
    var FileListing = []; 

    var connect = function(){ 
     //TODO JRF 19.01.2012 : re-enable this when bondi is fixed 
     // this.HomeDirectory.replace(/\/?$/, "/"); 
     FileListing = this._Get(Folder); 

     return true; 
    } 

    var i = 1; 
    do{ 
     var res = false; 
     try { 
     res = connect(); 
     }catch(e){ 
      Debug.LogInfo(e.message); 
     } 
     i++; 
     Server.Sleep(i*2000); 
    } while(res==false && i < Retries); 

    return FileListing; 
} 

답변

2

res = connect.call(this) 대신 res = connect()보십시오.

+0

pop pop! 그 작품. 덕분에 ... 이제는 모두 의미가 있습니다 +1 – Jason

+0

connect()에 제공해야하는 인수가 있으면 어떻게됩니까? 이 경우가 아니라 미래에? – Jason

+0

'connect.call (this, arg1, arg2/* etc * /)'. 기본적으로'.call()'은'()'보다 하나 더 많은 인자를 취하고, 첫번째 인자는'this'가 무엇인지 알려줍니다. –

관련 문제