jade模板报 Cannot read property 'length' of undefined
发布于 15 小时前 作者 jeff-ccj 88 次浏览 来自 问答

json:

[ { _id: 570f2f0b417a527aa1fef46d,
    name: 'test',
    time: 
     { date: Thu Apr 14 2016 13:47:55 GMT+0800 (CST),
       year: 2016,
       month: '2016-4',
       day: '2016-4-14',
       minute: '2016-4-14 13:47' },
    title: '333',
    tags: null,
    content: null,
    comments: [],
    reprint_info: {},
    pv: 0 },
  { _id: 570f2e9524c84052a1bfacf2,
    name: 'test',
    time: 
     { date: Thu Apr 14 2016 13:45:57 GMT+0800 (CST),
       year: 2016,
       month: '2016-4',
       day: '2016-4-14',
       minute: '2016-4-14 13:45' },
    title: '123321',
    tags: null,
    content: null,
    comments: [],
    reprint_info: {},
    pv: 0 } ]

node代码:

return res.render('user', {
  title: uName + '的微博'
  , blogs: data
});

jade代码:

.blog.row
  -each blog in blogs
    .blogList.col-xs-12.col-sm-6
      .media
        .media-left
          a(href='#')
            img.media-object(src='...', alt='图片')
        .media-body
          h4.media-heading
            a(href='/user/' + blog.name) #{blog.name}
            span 说
          div #{blog.time.minute}
          div  #{blog.title}
		  ```
回到顶部