我试图在 Jade 模板中使用 case 语句来设置表格行的背景颜色,但我收到了一个我似乎无法确定的错误。
这是代码:
each photog, i in thelist.ptlist
case photog.currentStatus
when "green": tr(style="background-color:#9f9")
when "amber": tr(style="background-color:#ff9")
when "red": tr(style="background-color:#f99")
default: tr(style="background-color:#99f")
td.
#{photog.currentStatus}
我收到的错误是“意外的标记‘标签’,预期的‘时间’、‘默认’或‘换行符’”,表示“td”。我尝试在 td 之前添加一个 blan 行,但我得到了完全相同的错误。
我尝试了文档提供的布局/语法的细微变体,但无济于事。有人可以告诉我哪里出错了吗?
最佳答案
td
标签与默认值对齐,因此可以通过 case 语句继承。通过删除多余的空格将 td
放在 case 之外。
关于javascript - Jade 案声明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38198315/