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

     
     
  • 相关阅读:
    php system()和exec()差别
    linux目录中 /usr/local/bin 和 /usr/bin和/usr/local/etc
    mac rar命令相关
    php迭代器
    linux下的find文件查找命令与grep文件内容查找命令
    php 类中的静态属性
    mysql 语句执行顺序
    mysl
    MySQL中concat函数
    animation效果
  • 原文地址:https://www.cnblogs.com/yeminglong/p/10156800.html
Copyright © 2011-2022 走看看