【问题标题】:Jade Template if statementJade 模板 if 语句
【发布时间】:2014-11-21 20:53:46
【问题描述】:

我有一个玉模板文件,我试图在每个循环中运行基于 JSON 对象的条件。我做错了什么让 if 语句起作用?

                each content in result.content
                  .panel.panel-default.result
                    .panel-heading.clearfix
                      a.gray(href='/content/#{content.id}') #{content.created_pretty}
                      a.btn.btn-primary.btn-sm.view(href="/content/#{content.id}") View
                      .status
                        .well
                          span.label.label-default #{content.priority}
                        if "#{content.priority}" == "URGENT"
                          .well
                            span.badge !

如果我将条件更改为

 if "URGENT" == "URGENT"

代码运行成功。

我也试过了:

 if '"#{content.priority}" == "URGENT"'
 - if ("#{content.priority}" == "URGENT")

任何 hlp 将不胜感激!

【问题讨论】:

    标签: node.js if-statement pug each


    【解决方案1】:

    你必须这样做

    if content.priority == "URGENT"
    

    而不是

    if "#{content.priority}" == "URGENT"
    

    【讨论】:

      猜你喜欢
      • 2016-10-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-10-17
      • 1970-01-01
      • 1970-01-01
      • 2017-03-29
      相关资源
      最近更新 更多