【发布时间】:2016-04-01 19:58:48
【问题描述】:
我有一个需要传递的数组来表达、渲染,然后在 Jade 端迭代以显示所有结果,但是下面的函数不起作用。它只显示一条数据,来自数组的五次。预期的行为是它将遍历数组并显示模板中的每个对象之一。
jade 和 express 的语法是否正确?文档很简单。
快递
router.get('/', function(req, res, next){
weekendPlans(function(err, theWeekend) {
if (err) throw err
console.log(theWeekend);
res.render('index', {theWeekend : theWeekend});
});
翡翠
h2 On This Weekend
.scroll
each result, i in theWeekend
div.title
#[a(target="_blank" href="#{theWeekend.url}") #{theWeekend.title}]
p WHEN: #{theWeekend.selectedDate}
数据
{ _id: 56fe9fe71f84acc2564b9fe8,
url: 'http://www.timeoutshanghai.com/features/Blog-Food__Drink/35271/Baristas-showcase-latte-art-in-Shanghai.html',
title: 'TIMEOUT',
selectedDate: Sat Apr 02 2016 01:00:00 GMT+0100 (BST),
__v: 0 }
【问题讨论】: