技术的坑分享记录

【笔记】使用jquery tmpl开发过程中遇见一个问题: 

有两个data数组是通过一个parendID 关联的;

如何在循环中添加父子关系;

参考: https://www.cnblogs.com/jyjin/p/4180392.html

  {{each(i,data) Array}} 类似jquery each,‘i’表示索引,‘data’表索引对象的对象通过对象点属性遍历,中间嵌入{{if}}可实现逻辑操作
将上处模板更改如下:
  {{each(i) family}}
    <li class="li">      ${family[i].relation}:${family[i].name}
    </li>
  {{/each}}


具体实现: 

 {{each(i) province}}
                    <div class="panel panel-success">
                        <div class="panel-heading">
                            <strong>${ProvinceName}</strong>
                        </div>
                        <div class="panel-body">
                            {{each(j) city}}
                            {{if CheckProvinceIdIsCity(province[i].Id, city[j].ProvinceId)}}
                            <span class="label label-info">
                                ${CityName}
                            </span>
                            {{/if}}
                            {{/each}}
                        </div>
                    </div>
                    {{/each}}


上下篇:

相关推荐