Using {{each}} in a template with an array of arrays

 

 <script id="DeptTemplate" type="text/x-jquery-tmpl">
        <li>
            Title:${Name}
            {{each Emp}}
            <br />${$index+1}:${$value}
            {{/each}}
        </li>
    </script>
    <ul id="deptList"></ul>
    <script>
        var deptlist = [
        { Name: "销售部", Emp: ["张三", "李四", "李四", "李四", "李四", "李四"] },
        { Name: "网络部", Emp: ["王二", "李四", "李四", "李四"] }
        ];
        $("#DeptTemplate").tmpl(deptlist).appendTo("#deptList");
    </script>

 

原文地址:https://www.cnblogs.com/xiaoxiaof/p/3985858.html