Case
jade中的case
类似js中的switch
语句。
当前一个when
中无语句的时候,将一直往下直至遇到一个有语句的when
才跳出。
jade:
case friends
when -1 //- 执行when 1中的语句
when 0
p you have no friends
when 1
p you have a friend
default
p you have #{friends} friends
html:
<p>you have 10 friends</p>
case
还有另外一种写法。注意:
后需接一个空格,后面内容若换行会报错。
jade:
- var friends = 1
case friends
when 0: p you have no friends
when 1: p you have a friend
default: p you have #{friends} friends
html:
<p>you have a friend</p>