2017-09-25 187 views
-1

請幫我迭代下面的對象數組。我能看到在控制檯對象的數組,但在玉我不能重複它在jade上迭代對象數組

[{title: "Stamp. The Hobbit", description: "Stamp. <b>The Hobbit</b>. I know 
it was on Friday …n the day when there was not a lot of creativity.", 
originalLink: null, summary: null, date: "2017-09-25T06:42:50.000Z"} 
{title: "Fall/winter Tolkien/LOTR events: your &#39;go-to&#39; list", 
description: "Audiences will thrill to the music from his legend…bbit</b> 
with scores from his films: The&nbsp;...", originalLink: null, summary: 
null, date: "2017-09-25T05:26:15.000Z"}, 
{title: "Watch what happens when Darth Vader swaps galaxy far, far away ... 
for Middle Earth", description: "The narrative of Middle Earth: Shadow of 
War is ba…nts of <b>The Hobbit</b> and The Lord of&nbsp;...", originalLink: 
null, summary: null, date: "2017-09-25T03:56:15.000Z"} 
{title: "The hobbit sword", description: "Posted by alex in kids/baby 
stuff, toys in Munster, Cork. 24 September 2017...210966215.", originalLink: 
null, summary: null, date: "2017-09-24T19:30:12.000Z"} 
{title: "The hobbit as high fantasy essay", description: "Im science teacher 
is stupid hes making me write a… like r u serious. Problems of urbanization 
essay", originalLink: null, summary: null, date: "2017-09-24T19:26:02.000Z"} 
{title: "Lego The Hobbit Bagend Bundle", description: "Lego <b>The 
Hobbit</b> Bagend Bundle, Used Lego &a…, Dublin, Ireland for 130.00 euros on 
Adverts.ie.", originalLink: null, summary: null, date: "2017-09- 
24T10:42:38.000Z"}] 

服務器代碼: res.render(「指數」,{AAA:JSON.stringify(結果)}) ;

玉:

extends layout 

    block content 

    script. 
    console.log("hi"); 
    var bbb = !{aaa} 
    console.log(bbb) 

    each value in bbb 
    p= value.title 
+0

目前尚不清楚這個問題正在解決哪個問題。 –

+0

1st block是我試圖迭代的對象數組。第二塊是我嘗試迭代的玉器。 –

回答

0

我想你只需要設置value.title這樣的:

each value in bbb 
    p !{value.title} 

希望它能幫助。

+0

它不工作... –

+0

C:\ heroku \ checkRepository \ views \ index.jade:14 12 | 13 | > 14 |每個值在bbb 15 |中p!{value.title} 16 | 17 |無法讀取未定義的屬性「長度」 TypeError:C:\ heroku \ checkRepository \ views \ index.jade:14 12 | \t 13 | \t > 14 | \t bbb中的每個值 15 | \t \t p!{value.title} 16 | 17 | 無法讀取未定義的屬性「長度」 –