为了账号安全,请及时绑定邮箱和手机立即绑定

node.js 遍历报错

node.js 遍历报错

慕勒4207555 2017-03-15 12:02:02
extends ../layout block content .container .row each item in movies .col-md-2 .thumbnail a(href="/movie/#{item._id}") img(src="#{item.poster}", alt="#{item.title}") .caption h3 #{item.title} p: a.btn.btn-primary(href = "/movie/#{item._id}", role ="button") 观看预告片为什么第6行一只在报错呢,错误贴在下方:TypeError: E:\NodeMovie\imooc\views\pages\index.jade:6    4| .container    5| .row  > 6| each item in movies    7| .col-md-2    8| .thumbnail    9| a(href="/movie/#{item._id}")Cannot read property 'length' of undefined    at eval (eval at <anonymous> (E:\NodeMovie\imooc\node_modules\jade\lib\index.js:218:8), <anonymous>:103:31)    at eval (eval at <anonymous> (E:\NodeMovie\imooc\node_modules\jade\lib\index.js:218:8), <anonymous>:224:4)    at eval (eval at <anonymous> (E:\NodeMovie\imooc\node_modules\jade\lib\index.js:218:8), <anonymous>:240:22)    at res (E:\NodeMovie\imooc\node_modules\jade\lib\index.js:219:38)    at Object.exports.renderFile (E:\NodeMovie\imooc\node_modules\jade\lib\index.js:380:38)    at Object.exports.renderFile (E:\NodeMovie\imooc\node_modules\jade\lib\index.js:370:21)    at View.exports.__express [as engine] (E:\NodeMovie\imooc\node_modules\jade\lib\index.js:417:11)    at View.render (E:\NodeMovie\imooc\node_modules\express\lib\view.js:128:8)    at tryRender (E:\NodeMovie\imooc\node_modules\express\lib\application.js:640:10)    at EventEmitter.render (E:\NodeMovie\imooc\node_modules\express\lib\application.js:592:3)
查看完整描述

1 回答

?
weibo_迪亚波罗1982_6_0

TA贡献1条经验 获得超0个赞

你没有传movies的值到index.jade

res.render('index',{
    title: '你的title',
    movies: [{...}]
});

movies的值应该是从mongodb查询出来的

查看完整回答
反对 回复 2017-03-15
  • 1 回答
  • 0 关注
  • 1320 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信