js遍历获取每行显示固定条数插入div包裹,结尾判断

2019-12-26 00:00:00 by 【6yang】, 111 visits, 收藏 | 返回
<!-- 库存获取数据 -->
<script type="text/template" id="j-inventory-tpl">
<%var good_index = 0; var good_len = Object.keys(data).length, perNum = 5;%>
<% _.each(data, function(n,i,c){ %>
<%if(good_index%perNum==0){%>
  <div class="fake-tr">
<%}%>
    <div class="fake-td t-c"><img src="<%=n.icon%>" alt=""></div>
<%if((good_index+1)%perNum==0 || good_index == good_len-1 ){%>
  <input type="checkbox" name="sel-all" class="sel-all" />
  </div>
<%}%>
<%good_index++%>
<% }); %>
<%  %>
</script>
分享到:
share

    图片原图

    loading

    loading