码迷,mamicode.com
首页 > Web开发 > 详细

doT js模板入门 3

时间:2015-07-16 20:03:36      阅读:277      评论:0      收藏:0      [点我收藏+]

标签:模板   dot   js模板   

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‘}}已支付 {{?? }}已购买&nbsp;
                    {{=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 入门
作者:黄威(1287789687@qq.com)

版权声明:本文为博主原创文章,未经博主允许不得转载。

doT js模板入门 3

标签:模板   dot   js模板   

原文地址:http://blog.csdn.net/hw1287789687/article/details/46913859

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!