在 pug 中显示对象数组

问题描述

我对 nodejs 很陌生。如何在 pug 中显示对象数组?请帮忙

所以这是 Admin 架构

{        
  "_id": "868","name": "James","__v": 0,"affiliatelink": [
    {
      "storeId": "12345","storeName": "white choc","linkview": 1
    },{
      "storeId": "67890","storeName": "dark choc","linkview": 2
    },]
}

{        
  "_id": "135","name": "Marrie","affiliatelink": []
}


我当前的代码

if (req.session.admin.level == 'admin') {
            Admin.find({},{name : 1,email : 1,level : 1,affiliatelink : 1,createdAt : 1,}).exec((err,admins)=>{
            admins.sort((a,b)=>{
                return b.createdAt - a.createdAt;
            })
            console.log(admins)
            res.render('modules/admin/affiliate',{title: 'Admin List',admins : admins,admin : req.session.admin,message: message});
        })
    }
 

这是我在 pug 中的代码

tbody
        each item in admins
          tr(data-item-id='1')
            td
            td 
              | #{item.name}
            td 
              | #{item.email}
            td 
              | #{item.level}
            td 
              | #{item.affiliatelink.store}
            td 
              | #{item.affiliatelink.linkview}  
            td.actions

这是当前的显示。如您所见,Store and Click 是空的。它应该显示一些数据。

enter image description here

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)