用例(Case)
¥Case
case
语句是 JavaScript switch
语句的简写。它采用以下形式:
¥The case
statement is a shorthand for JavaScript’s switch
statement. It takes the following form:
用例下降(Case Fall Through)
¥Case Fall Through
你可以使用 fall through,就像在 JavaScript switch
语句中一样。
¥You can use fall through, just as you would in a JavaScript switch
statement.
然而,不同之处在于,每当未显式包含 break
语句时,JavaScript 就会失败;在 Pug 中,只有当一个块完全丢失时才会发生这种情况。
¥The difference, however, is a fall through in JavaScript happens whenever a break
statement is not explicitly included; in Pug, it only happens when a block is completely missing.
如果你不想在特定情况下输出任何内容,请添加显式的无缓冲 break
:
¥If you would like to not output anything in a specific case, add an explicit unbuffered break
:
块扩展(Block Expansion)
¥Block Expansion
也可以使用块扩展:
¥Block expansion may also be used: