Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/oop/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
这不是一个函数-javascript oop和原型_Javascript_Oop_Prototype - Fatal编程技术网

这不是一个函数-javascript oop和原型

这不是一个函数-javascript oop和原型,javascript,oop,prototype,Javascript,Oop,Prototype,我使用的是类似于NodeJS的bondi,它构建在Firefox js引擎上。。基本上我得到了这个错误,我相信这是由于我在下面的.Get函数中引用“this”的方式造成的 基本上有一个叫做SFtpClient的工具。它有“Get”的方法,列出文件夹的内容,但我想用一个包含文件的下拉列表来更改原型。我需要改变它,这样它 a/失败时会重试几次,b/它有一个递归文件夹列表功能 所以我用原型来改变它-移动。开始 有人知道我为什么会出错吗: Jan 23 04:51:34 beta bondi: ===

我使用的是类似于NodeJS的bondi,它构建在Firefox js引擎上。。基本上我得到了这个错误,我相信这是由于我在下面的.Get函数中引用“this”的方式造成的

基本上有一个叫做SFtpClient的工具。它有“Get”的方法,列出文件夹的内容,但我想用一个包含文件的下拉列表来更改原型。我需要改变它,这样它 a/失败时会重试几次,b/它有一个递归文件夹列表功能

所以我用原型来改变它-移动。开始

有人知道我为什么会出错吗:

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.\u Get=SFtpClient.prototype.Get;
SFtpClient.prototype.Get=函数(文件夹,重试){
//默认值
如果(!Retries)Retries=5;
如果(!Folder)Folder=“~/”;
//瓦尔斯
var FileListing=[];
var connect=function(){
//TODO JRF 19.01.2012:修复bondi后重新启用此功能
//此.homeditory.replace(/\/?$/,“/”);
FileListing=this.\u Get(文件夹);
返回true;
}
var i=1;
做{
var-res=false;
试一试{
res=connect();
}捕获(e){
Debug.LogInfo(e.message);
}
i++;
服务器睡眠(i*2000);
}而(res==false&&i
尝试
res=connect.call(this)
而不是
res=connect()

如果需要为connect()提供参数,会发生什么?不是在这种情况下,而是在将来?
connect.call(this,arg1,arg2/*etc*/)
。基本上,
.call()
()
多接受一个参数,第一个参数告诉它这个
将是什么。你也可以使用
.apply()
,它与
.call()
完全相同,但它接受一个参数数组作为第二个参数:
connect.apply(这个,[arg1,arg2,/*等*/)
。非常适合模拟
super
调用,如
this.\u originalPrototypeFunction(this,arguments)
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;
}