您的位置:首页 > 其它

Jade之Case

2015-11-22 17:00 204 查看

Case

jade中的
case
类似js中的
switch
语句。

当前一个
when
中无语句的时候,将一直往下直至遇到一个有语句的
when
才跳出。

jade:

- var friends = 10 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>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: