dot.js使用:
1.数据显示:
var tmpl = doT.template($("#insuredViewListTemp")[0].text);var tmplEidt = doT.template($("#insuredEditListTemp")[0].text);$("#insuredViewList").html(tmpl(data));$("#insuredEditList").html(tmplEidt(data));
说明:insuredViewList:容器id;insuredViewListTemp是js模板id。
列表循环遍历:
(type="text/x-dot-template")
<script type="template" id="beneficiaryViewListTemp"> ???????{{ for(var prop in it) { }} ???????<ul class="ulList_common ulList_commonView1 favoreeDetail"> ???????????<li class="personName"><span>{{=replaceNull(it[prop].name)}}</span><img ???????????????????src="../img/male.png"/></li> ???????????<li> ???????????????<label>与被保险人关系:</label><span>{{=replaceNull(it[prop].relation)}}</span> ???????????????<em>|</em> ???????????????<label>证件号码:</label><span>{{=replaceNull(it[prop].identityNo)}}</span> ???????????????<em>|</em> ???????????????<label>受益比例:</label><span>{{=replaceNull(it[prop].benefitProportion)}}<em>%</em></span> ???????????</li> ???????</ul> ???????{{ } }}</script>
===================================
2.if else判断:
{{? it.sex === 0}}<img src="../img/female.png"/>{{?? it.sex === 1}}<img src="../img/male.png"/>{{?}}
<p><label class="info-a">状态:</label><label class="info-b"> ???{{? it[intentionKey].status===0 }}未审核 ???{{?? it[intentionKey].status===1 }}审核通过 ???{{?? it[intentionKey].status===2 }}意向撤销 ???{{?? it[intentionKey].status===3 }}转预约 ???{{?? it[intentionKey].status===4 }}转预约撤销 ???{{?? }}无此状态 ???{{? }}</label></p>
dot.js的使用
原文地址:https://www.cnblogs.com/super-chao/p/8392361.html