【发布时间】:2015-02-20 23:29:33
【问题描述】:
我正在将 express 4 与玉一起使用。我在玉模板中有这样的错误:
文件:test.jade,data.item.test 未定义:
extends layout
block content
if data.item.test
div.content-section
html 响应如下所示:
TypeError: /work/web/views/layout.jade:37
35| header
36| i.arrow-up
> 37| h4.user-name #{user.firstName.charAt(0).toUpperCase() + user.firstName.slice(1)} #{user.lastName.charAt(0).toUpperCase() + user.lastName.slice(1)}
38| a(href="/profile").edit-profile
39| i
40| | Edit Profile
Cannot read property 'firstName' of undefined
如果我修复了翡翠模板中的实际错误,一切都会正常工作,并且布局中不会报告错误。
如何解决这个问题,因为很难在翡翠模板中调试错误
【问题讨论】:
-
您的用户未定义,因此您需要定义它。不能提供更多建议,因为您没有显示用户在哪里被传递。