gpt4 book ai didi

其他类函数中的Javascript类实例(nodejs)

转载 作者:行者123 更新时间:2023-11-30 05:38:04 25 4
gpt4 key购买 nike

我和 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

最佳答案

您正在传递未定义的条件,我假设您想要传递这个条件。

this.criteria = new StationSearchCriteria(this.minLat(), this.minLong(), this.maxLat(), this.maxLong());
this.conn = new StationDAO(this.criteria); //this should work

关于其他类函数中的Javascript类实例(nodejs),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22374883/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com