jade基础

1、根据缩进,规定层级

2、属性放在()里面,逗号分隔,内容空个格 直接往后堆

a(href="www.baidu.com", title="aaa") 百度
||
<a href="www.baidu.com">百度</a>

style属性与class属性比较特殊,也可以用如下写法:

div(style={background: res; width: 100px;})
div(class= ["aaa", "bbb"] class="active")  //可以放多个class,编译时会自动融合

3、class id 的简写

div.classname  === <div class="classname"></div>
div#id  ===  <div id="id"></div>

4、属性的特殊写法

div&attributes({title:'title', id='id'})
5、| 代表原样输出
html
  head
    body
      |abc

6、.代表所有的下一级的东西原样输出

html
  head
    script.
      window.onload = function() {...}
    body
      |abg

7、include引用, 不增加http请求数,直接编译到页面中

html
  head
    script
      include a.js
  body
    |abg

8、变量 #{}  内部也可以进行运算

html
  head
  body
    div 我的名字是 #{name}

ps: style 与 class  直接放入变量即可

9、 - 意味着我是一段代码

html
  head
  body
    -var a =1
    -var b = 2
    div #{a+b}
    div=a  === div #{a} 这两个写法是等价的

10、循环

html
  head
  body
    -for(var i=0; i<arr.length; i++)
      div=arr[i]

11、! 代表 html 原样输出

content = “<a>dfsdf</a>”;

html
  head
  body
    div!=content

12、if 语句

html
  head
  body
   -var a = 12
   -if(a%2 == 0)
     div(style={background:red})
   -else
     div(style={background:blue})

13、类似于switch语句 。case when

html
  head
  body
  -var a =1
  case a
    when 0
      div aaa
    when 1
      div bbb
    default
      |不靠谱


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值