我处理nodejs,我无法弄清楚,为什么我不能从另一个类函数调用类实例。这是我的代码。请帮忙。
var StationDAO = require('./StationDAO.js');
var StationSearchCriteria = require('./StationSearchCriteria.js');
function GasStationService(lat, long, zoom) {
this.latitude = lat;
this.longitude = long;
this.zoom = zoom;
this.zoomToKilometers = 0.009;
/* ......... */
this.minLat = function () {
return this.latitude - this.zoomToKilometers;
};
this.minLong = function() {
return this.longitude - this.zoomToKilometers;
};
this.maxLat = function() {
return this.latitude + this.zoomToKilometers;
};
this.maxLong = function() {
return this.longitude + this.zoomToKilometers;
};
this.criteria = new StationSearchCriteria(this.minLat(), this.minLong(), this.maxLat(), this.maxLong());
this.conn = new StationDAO(criteria); // why this doesnt work
答案 0 :(得分:1)
您正在传递未定义的标准我假设您想要传递this.criteria isntead。
this.criteria = new StationSearchCriteria(this.minLat(), this.minLong(), this.maxLat(), this.maxLong());
this.conn = new StationDAO(this.criteria); //this should work