Node.js 从循环中获取输出后执行渲染函数 module.exports={ getHomePost:函数(请求、恢复){ post_model.getHomePosts('1',函数(err,行){ 变量局部变量={}; 异步并行([ 函数(回调){ 对于(var i=0;i

Node.js 从循环中获取输出后执行渲染函数 module.exports={ getHomePost:函数(请求、恢复){ post_model.getHomePosts('1',函数(err,行){ 变量局部变量={}; 异步并行([ 函数(回调){ 对于(var i=0;i,node.js,asynchronous,sync,Node.js,Asynchronous,Sync,这可能有助于你 module.exports= { getHomePost:function(req,res) { post_model.getHomePosts('1',function(err,rows) { var locals={}; async.parallel([ function(callback) { for(var i=0;i<rows.length-1;i++) { async.series([ fun

这可能有助于你

module.exports= {
getHomePost:function(req,res) {
post_model.getHomePosts('1',function(err,rows) {
  var locals={}; 
  async.parallel([
    function(callback) {
      for(var i=0;i<rows.length-1;i++) {
        async.series([ 
          function(call){
            post_model.getPostDetails(rows[i].Post_Date_Time_id,rows[i].Post_Personid_id,function(err,row) {
              locals.rows[]=row;
              call();
           });
          }  
        ],function(err){ 

        //console.log(locals.rows);
        });
      } 
      callback();
    }
  ],function(err) {
    console.log(locals.rows);
    res.render('home',locals);
  });
});
}
} 
module.exports=
{
getHomePost:函数(请求、恢复)
{
post_model.getHomePosts('1',函数(err,行)
{
变量局部变量={};
异步并行([
函数(回调)
{
var计数=0;

对于(var i=0;我能有人帮我做这件事.)。。
  module.exports= 
    {
        getHomePost:function(req,res) 
        {
            post_model.getHomePosts('1',function(err,rows) 
            {
                var locals={}; 
                async.parallel([
                function(callback) 
                {
                    var count = 0;
                    for(var i=0;i<rows.length-1;i++) 
                    {
                        async.series([ 
                        function(call)
                        {
                            post_model.getPostDetails(rows[i].Post_Date_Time_id,rows[i].Post_Personid_id,function(err,row) 
                            {
                                locals.rows[]=row;
                                call();
                            });
                        }],
                        function(err)
                        { 
                            //console.log(locals.rows);
                        });
                        count++;
                    } 
                    if(count == rows.length)
                    {
                        callback();
                    }
                }],
                function(err) 
                {
                    console.log(locals.rows);
                    res.render('home',locals);
                });
            });
        }
    }