【问题标题】:express 4 jade invalid error快递4玉无效错误
【发布时间】: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

如果我修复了翡翠模板中的实际错误,一切都会正常工作,并且布局中不会报告错误。

如何解决这个问题,因为很难在翡翠模板中调试错误

【问题讨论】:

  • 您的用户未定义,因此您需要定义它。不能提供更多建议,因为您没有显示用户在哪里被传递。

标签: node.js express pug


【解决方案1】:

原来问题出在错误模板上。它使用与其他页面相同的布局,并且那里需要用户,但不是从错误处理程序发送的。

【讨论】:

    猜你喜欢
    • 2015-11-25
    • 2015-08-18
    • 2013-11-16
    • 2011-05-19
    • 2015-05-11
    • 2011-11-18
    • 1970-01-01
    • 1970-01-01
    • 2016-01-10
    相关资源
    最近更新 更多