我有以下非功能代码
div(class = "col-xs-8 inner")
| <label style="font-size:20px;"><%- meter_id %></label><br>
if (type === "1")
| Electricity
if (type === "0")
| Water
我传递的类型为1,我仍然在输出中看到电和水。我不确定我错在哪里。
答案 0 :(得分:1)
在两个if
语句之后,你错过了一定程度的缩进:
div(class = "col-xs-8 inner")
| <label style="font-size:20px;"><%- meter_id %></label><br>
if (type === "1")
| Electricity
if (type === "0")
| Water
这是因为Pug只将缩进代码与这些块相关联。也就是说,在if
- 语句之后,它期望属于其分支的代码缩进。