想给变量数组填充内容,但是发现回调后,因为作用域的原因而没有改变原值varlist=newArray();functionget_time_line(){varvalue=newArray();//value是一个空数组list.forEach(function(key,i){db.hget(key,'time_line',function(err,reply){value[key]=reply;//这里想读取redis的相应值,给value填充内容});});res.render('index',{value:value});console.log(value);//但是输出却是空的[]db.quit;};functionget_Index(){db.keys('tencent:uid:*',function(err,replies){replies.forEach(function(key,i){list.push(key);});get_time_line();});}请问怎么才能把value的值填充完后再调用?
相关分类