简体   繁体   中英

Outputting JSON data from an object in an array. Pug (Jade)

Outputting JSON data from an object in an array. I use Pug (Jade).

I'm trying like this:

h1.main-title.center Changelog
    each log in changelog
      .changelog-item
        .second-title 
          span= log['ver']
          span.text-hide= log['date']
        .changelog-item__log
          .row
            .col-xs-3
              span.label.label--success= log.do['title']
            .col-xs-9
              span= log.do['text']

Json:

{
  "log1": {
    "ver" : "1.0.0",
    "date" : " - 31 July 2018",
    "do" : [

      {
        "label" : ".label--success ",
        "title" : "Add",
        "text" : "Changelog Page"
      },
      {
        "label" : ".label--danger ",
        "title" : "Fixed",
        "text" : "Navbar"
      }
    ]
  },
  "log2": {
    "ver" : "1.0.2",
    "date" : " - 31 July 2018",
    "do" : [

      {
        "label" : ".label--success ",
        "title" : "Add something",
        "text" : "Changelog Page something"
      },
      {
        "label" : ".label--danger ",
        "title" : "Fixed something",
        "text" : "Navbar something"
      }
    ]
  }
}

Displays only ver and date .

log.do['text'] and log.do['title'] is not working.

but simple objects is working well.

What am I doing wrong?

do is a reserved keyword in javascript. Try renaming that property to something like "actions".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM