配列を持っています。すべての結果を表示するために、表現するために渡す必要がある配列を持っています。ただし、以下の関数は動作しません。配列から5倍のデータが1つだけ表示されます。予想される動作は、配列をループし、テンプレート内の各オブジェクトの1つを表示することです。オブジェクト配列を反復して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 }
私はそれを以前に試みましたが、データなしで5つの結果が得られました。とても混乱するような。他のアイデア? –
console.log(theWeekend)の出力は何ですか? ? – Nicole
出力は元の質問のデータです –