javascript - 如何在 Jade 中使用 if 和 else

标签 javascript pug

我不知道如何在 Jade 文件中使用 if 和 else。

我有:

br
                    each test in changes
                        .change-row
                            if test.property == "Image"
                             strong #{test.property}
                            else{
                            strong #{test.property}
                            span :  #{test.newValue}
                            }

最佳答案

您必须从 else 中删除大括号并正确缩进代码。

br
each test in changes
  .change-row
    if test.property == "Image"
      strong #{test.property}
    else
      strong #{test.property}
      span :  #{test.newValue}

参见http://learnjade.com/tour/conditionals/了解更多信息

关于javascript - 如何在 Jade 中使用 if 和 else,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40912370/

相关文章:

javascript - 错误 : document is not defined

javascript - vue.js:带有自托管(本地)视频文件的英雄背景视频

javascript - AngularJs location.path 不传递参数

javascript - 使用 href 时,Jade 模板不会输出正确的 html

javascript - 带有功能性关闭按钮的弹出窗口(HTML、CSS、JavaScript)

javascript - JavaScript 中的双重 for 循环

javascript - CKEDITOR 意外地剥离了我在 HTML 表格中的自定义标签

javascript - 如何从 Javascript 调用 Jade 文件中的函数

node.js - 为什么我的所有图像都没有显示?

javascript - Jade to HTML > 以jade文件命名的目录中的index.html