我该如何处理这个问题?我的玉文件是:
extends layout
block content
h1.
User List
ul
each user, i in userlist
li
a(href="mailto:#{user.email}")= user.username
我收到以下错误:
TypeError: C:\node\nodetest1\views\userlist.jade:7
5| User List
6| ul
> 7| each user, i in userlist
8| li
9| a(href="mailto:#{user.email}")= user.username
Cannot read property 'length' of undefined
at eval (eval at <anonymous> (C:\node\nodetest1\node_modules\jade\lib\jade.js:174:8), <anonymous>:56:31)
at eval (eval at <anonymous> (C:\node\nodetest1\node_modules\jade\lib\jade.js:174:8), <anonymous>:99:4)
at eval (eval at <anonymous> (C:\node\nodetest1\node_modules\jade\lib\jade.js:174:8), <anonymous>:112:22)
at res (C:\node\nodetest1\node_modules\jade\lib\jade.js:175:38)
at Object.exports.render (C:\node\nodetest1\node_modules\jade\lib\jade.js:300:10)
at Object.exports.renderFile (C:\node\nodetest1\node_modules\jade\lib\jade.js:336:18)
at View.exports.renderFile [as engine] (C:\node\nodetest1\node_modules\jade\lib\jade.js:321:21)
at View.render (C:\node\nodetest1\node_modules\express\lib\view.js:76:8)
at Function.app.render (C:\node\nodetest1\node_modules\express\lib\application.js:527:10)
at ServerResponse.res.render (C:\node\nodetest1\node_modules\express\lib\response.js:900:7)
答案 0 :(得分:0)
显然你还没有将userlist
对象发送给Jade。你需要像这样呈现它:
res.render('userlist', {userlist: userlist});
第三次出现userlist
你的对象。