zoukankan      html  css  js  c++  java
  • art.template 循环里面分组。

     

    后台提供给我们一个数组,我们要用模版实现上面的格式输出怎么版呢?

    下面就是解决方案:

    <h2>循环4个一组</h2>
    <script type="text/html" id="temp1">
        <b>
    {{each rows as item i}}
        {{if i%4==0}}<b>【{{/if}}
        {{item.userName}}
        {{if i>0 && (i-3)%4==0}}】</b>{{/if}}
    {{/each}}
    
        </ul>
    </script>
    
    <script>
        var data={
            "rows":[
                {"userName":"项目1"},
                {"userName":"项目2"},
                {"userName":"项目3"},
                {"userName":"项目4"},
                {"userName":"项目5"},
                {"userName":"项目6"},
                {"userName":"项目7"},
                {"userName":"项目8"},
                {"userName":"项目9"},
                {"userName":"项目10"},
                {"userName":"项目11"},
                {"userName":"项目12"},
                {"userName":"项目13"},
                {"userName":"项目14"},
                {"userName":"项目15"},
                {"userName":"项目16"},
                {"userName":"项目17"},
                {"userName":"项目18"},
                {"userName":"项目19"},
                {"userName":"项目20"}
            ]
        }
        var html=template("temp1",data)
    
        document.write(html)
    
    </script>

    如果这篇文章对您有帮助,您可以打赏我

    技术交流QQ群:15129679

     
     
  • 相关阅读:
    Java虚拟机一
    java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException
    Java虚拟机
    topcoder srm 663 div1
    topcoder srm 694 div1 -3
    topcoder srm 695 div1 -3
    topcoder srm 696 div1 -3
    topcoder srm 697 div1 -3
    topcoder srm 661 div1
    topcoder srm 698 div1 -3
  • 原文地址:https://www.cnblogs.com/yeminglong/p/10156800.html
Copyright © 2011-2022 走看看