【发布时间】:2015-02-01 06:15:51
【问题描述】:
我写了一个小玉脚本就是
ul.sidebar-nav
each(record in #{records})
li
a(href='#') #{record.sender}
我正在将一个记录数组对象传递给翡翠模板,但对于record 未定义。谁能解释一下为什么我会收到这个错误?
这是完整的错误:
/home/ritesh/Sample/Sample1/Sample/views/index.jade:9 7| each(record in #{records}) 8| li > 9| a(href='#') #{record.sender} 10| Cannot read property 'sender' of undefined
TypeError: /home/ritesh/Sample/Sample1/Sample/views/index.jade:9
7| each(record in #{records})
8| li
> 9| a(href='#') #{record.sender}
10|
Cannot read property 'sender' of undefined
at eval (eval at <anonymous> (/home/ritesh/Sample/Sample1/Sample/node_modules/jade/lib/index.js:216:8), <anonymous>:83:49)
at eval (eval at <anonymous> (/home/ritesh/Sample/Sample1/Sample/node_modules/jade/lib/index.js:216:8), <anonymous>:110:22)
at res (/home/ritesh/Sample/Sample1/Sample/node_modules/jade/lib/index.js:217:38)
at Object.exports.renderFile (/home/ritesh/Sample/Sample1/Sample/node_modules/jade/lib/index.js:360:38)
at View.exports.renderFile [as engine] (/home/ritesh/Sample/Sample1/Sample/node_modules/jade/lib/index.js:350:21)
at View.render (/home/ritesh/Sample/Sample1/Sample/node_modules/express/lib/view.js:93:8)
at EventEmitter.app.render (/home/ritesh/Sample/Sample1/Sample/node_modules/express/lib/application.js:530:10)
at ServerResponse.res.render (/home/ritesh/Sample/Sample1/Sample/node_modules/express/lib/response.js:933:7)
at /home/ritesh/Sample/Sample1/Sample/routes/index.js:13:7
at /home/ritesh/Sample/Sample1/Sample/node_modules/mongojs/node_modules/mongodb/lib/mongodb/cursor.js:172:16
【问题讨论】:
-
试试
each record in records,注意记录应该是一个数组。
标签: javascript node.js pug