doT js模板入門 3
阿新 • • 發佈:2018-03-03
per length handlebar .cn sheet link content 僅支持 emp
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])
doT js模板入門 3