<分区>
伙计们,我有以下 for 循环,在其中我从另一个模块调用 vehicles.alertsVid
函数,它返回每辆车的状态。结果确实到达了,但是稍后,并且没有正确添加。
正确的写法是什么,这样主 for 循环不会提前,temp.status
会及时写入? :)
for (var i = vehiclesStuff.length - 1; i >= 0; i--) {
var temp = {};
temp.name = vehiclesStuff[i].nickname.S;
temp.plate = vehiclesStuff[i].plate.S;
temp.base = vehiclesStuff[i].base.S;
temp.vin = vehiclesStuff[i].vin.S;
temp.vid = vehiclesStuff[i].vid.S;
var myfunc = function(t,results,done){return function(){
console.log ("ALERTS",results);
t.status = results.toString();
done();
}};
vehicles.alertsVid(temp.vid, myfunc(temp));
vehicleArray.push(temp);
};
callback()