for 循环前推断循环的list是否为空
<script id="invoiceListDot" type="text/x-dot-template">
{{? it.invoiceInfoDtos}}
{{ for(var prop=0;prop
<it.invoiceInfoDtos.length
; prop++){ }}
<div class="{{ if(prop==0){}}invoice-infor {{ }else {}}no-invoice{{ }}}" data-index="{{= prop }}">
<span class="no-ivoice-icon"></span>
<span>普通发票</span>
<span class="ivo-margin">{{= it.invoiceInfoDtos[prop].content }}</span>
<span class="ivo-margin">{{= it.invoiceInfoDtos[prop].title }}</span>
<span class="ivo-margin">{{= it.invoiceInfoDtos[prop].address }}</span>
<span class="ivo-margin">{{= it.invoiceInfoDtos[prop].receiver }}</span>
<span class="ivo-margin">{{= it.invoiceInfoDtos[prop].phone }}</span>
</div>
{{ } }}
{{?}}
</script>
if 推断
<li class="company-state">
{{? it.orgAppRelList[i].expire }}
{{=it.orgAppRelList[i].endDate }}已过期
{{?? }}
{{? it.orgAppRelList[i].isTrial }}
试用中的企业无法订购,<span class="warning">{{=it.orgAppRelList[i].endTime }}过期</span>
{{?? }}
{{? it.orgAppRelList[i].status==‘001‘ }} 未购买{{??
it.orgAppRelList[i].status==‘002‘}}
已支付 {{?? }}
已购买
{{=it.orgAppRelList[i].endDate }}过期
{{? }}
{{?}}
{{?}}
</li>
宏的使用
<div class="content" id="serviceItem">
{{##def.spaceUnit:
{{? it.productPrice.policyInfo.storageUnit==1 }}
K{{?? it.productPrice.policyInfo.storageUnit==2}}
M{{??
it.productPrice.policyInfo.storageUnit==3}}
G {{?? }}T {{? }}
#}}
<div class="buy-list">
<ul>
<li class="buy-name">购买时长:</li>
<li class="buy-select"><p>{{=it.productPrice.userPeriod}}个月</p></li>
<li class="buy-unit"></li>
<li class="buy-state">估计到期时间:{{=it.productPrice.endTime}}</li>
</ul>
</div>
<div class="buy-list">
<ul>
<li class="buy-name">用户数:</li>
<li class="buy-select"><input name="userCount" onkeypress="eventUtil.onlyNumberKeyPress(event)"
type="text"></li>
<li class="buy-unit">人</li>
<li class="buy-state">用户单位价格 {{=it.productPrice.normalPriceDto.userPeriodPrice}}元/人
{{? it.productPrice.policyInfoDto.periodUnit==1 }}
年{{??
it.productPrice.policyInfoDto.periodUnit==2}}月{{??
it.productPrice.policyInfoDto.periodUnit==3}}天 {{?? }}单位未知 {{? }}
<span class="warning">(眼下仅仅支持200人以内的团队)</span></li>
</ul>
</div>
<div class="buy-list">
<ul>
<li class="buy-name">扩容空间(全部):</li>
<li class="buy-select"><input name="expansion_storage"
onkeypress="eventUtil.onlyNumberKeyPress(event)" type="text"></li>
<li class="buy-unit">{{#def.spaceUnit}}</li>
<li class="buy-state">空间单位价格 {{=it.productPrice.normalPriceDto.storagePrice}}元/
{{#def.spaceUnit}}
</li>
</ul>
</div>
</div>
參考:
doT js 入门
作者:黄威([email protected])