• jade-for-each-while


    if else还是for循环,在jade里面都是可执行的代码
    for循环
    - var lession = {course:'jade', level:'high'}
    - for (var k in lession)
      p= lession[k]
    =>
    <p>jade</p>
    <p>high</p>
    each
    - each value,key in lession
      p #{key}: #{value}
    =>
    <p>course: jade</p>
    <p>level: high</p>
    这个each里面的前面-可加可不加
    each value,key in lession
      p #{key}: #{value}
    =>
    <p>course: jade</p>
    <p>level: high</p>

    除了循环对象,还可以循环数组

    - var course = ['node', 'jade', 'express']
    - each item in course
      p= item
    - for (var item in course)
      p= course(item)
    =>
    <p>node</p>
    <p>jade</p>
    <p>express</p>
    <p>node</p>
    <p>jade</p>
    <p>express</p>

    要用这种in的形式,不能用for(item=0; item<course.lenght; item++)这种



    嵌套循环
    - var sections = [{id:1,items:['a','b']},{id:2,items:['c','d']}]
    dl
      each section in sections
      dt= section.id
        each item in section.items
        dd= item
    =>
    <dl>
      <dt>1
        <dd>a</dd>
        <dd>b</dd></dt>
      <dt>2  
        <dd>c</dd>
        <dd>d</dd></dt>
    </dl>
    while
    - var n = 0
    ul
      while n<4
      li=n++
    =>
    <ul>
      <li>0</li>
      <li>1</li>
      <li>2</li>
      <li>3</li>
    </ul>
  • 相关阅读:
    HTML5(3) 拖放(Drag 和 Drop)
    HTML5(2) 画布Canvas
    HTML5(1) 介绍
    C#(99):System.IO.Path文件路径类
    SQL Server(00):逻辑函数
    SQL Server(00):删除表中的重复数据
    DevExpress03、XtraGrid(1)基本应用
    DevExpress11、TreeList
    DevExpress10、RichEditControl
    XtraEditors五、SpinEdit、TimeEdit
  • 原文地址:https://www.cnblogs.com/wzndkj/p/9271676.html
Copyright © 2020-2023  润新知