我有两个模块:apirequest.js和feed.js。当我调用feed.start()
apirequest时,我得到TypeError: Object #<Feed> has no method 'start'
. 为什么是这样?不util.inherits(Feed, APIRequest);
继承 APIRequest 的属性?
apirequest.js
var EventEmitter = require('events').EventEmitter;
var util = require('util');
function APIRequest(endpoint) { }
APIRequest.prototype.start = function() { }
util.inherits(APIRequest, EventEmitter);
module.exports = APIRequest;
饲料.js
var util = require('util');
var APIRequest = require('../lib/api_request');
function Feed(endpoint) {
APIRequest.call(this, endpoint);
}
util.inherits(Feed, APIRequest);
var feed = new Feed(endpoint);
feed.start();