Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/mongodb/12.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原型继承基函数未定义_Javascript_Inheritance_Prototype - Fatal编程技术网

Javascript原型继承基函数未定义

Javascript原型继承基函数未定义,javascript,inheritance,prototype,Javascript,Inheritance,Prototype,试图掌握来自c#背景的OO原型香草javascript继承 我有一个基本的“类”,它执行HTTP GET。我想从中继承,这样子类就可以封装这个HTTP GET的变体 在下面的代码中,我在getUser函数中得到一个httpGet未定义错误。我的最终目标是调用一个简单的方法,比如userComms.getUser() 为什么我会出现错误?最灵活的方法是什么?注意这一点。在httpGet前面: function UserComms() { this.getUser = function ()

试图掌握来自c#背景的OO原型香草javascript继承

我有一个基本的“类”,它执行HTTP GET。我想从中继承,这样子类就可以封装这个HTTP GET的变体

在下面的代码中,我在
getUser
函数中得到一个
httpGet未定义
错误。我的最终目标是调用一个简单的方法,比如
userComms.getUser()


为什么我会出现错误?最灵活的方法是什么?

注意
这一点。
httpGet
前面:

function UserComms() {
    this.getUser = function () {
        // error thrown here:
        this.httpGet('user/get', function (data) {
            console.log(data);
        });
    }
}

注意
这个。
httpGet
前面:

function UserComms() {
    this.getUser = function () {
        // error thrown here:
        this.httpGet('user/get', function (data) {
            console.log(data);
        });
    }
}

注意
这个。
httpGet
前面:

function UserComms() {
    this.getUser = function () {
        // error thrown here:
        this.httpGet('user/get', function (data) {
            console.log(data);
        });
    }
}

注意
这个。
httpGet
前面:

function UserComms() {
    this.getUser = function () {
        // error thrown here:
        this.httpGet('user/get', function (data) {
            console.log(data);
        });
    }
}