关闭

do-T模板引擎

91人阅读 评论(0) 收藏 举报
分类:

数组


<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<ul id="MumberList">

</ul>
</body>
<script src="sea.js" type="text/javascript" charset="utf-8"></script>
<script src="dot.js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script src="doT.min.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">


var totalData = [123,223,334,445,556,667,778,889];

var result = '\
{{~it:value:index}}\
<p style="background:green">{{=value}}</p>\
{{~}}';
var template1 = doT.template(result);


$("#MumberList").append(template1(totalData));
</script>
</html>

对象==========================




<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<ul id="MumberList">

</ul>
</body>
<script src="sea.js" type="text/javascript" charset="utf-8"></script>
<script src="dot.js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script src="doT.min.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">


var totalData = [
{
code:'dongtao01',
name:'111111111'
},
{
code:'dongtao02',
name:'222222222'
},
{
code:'dongtao03',
name:'222222222'
},
{
code:'dongtao04',
name:'222222222'
},
]
//var totalData = [1,2,3,4,5,6,7,8]

var result = '\
{{~it:value:index}}\
<li class="mui-input-row  after_none" salerInfo={{=JSON.stringify(it[index])}}>\
<label class="mui-color-555">{{=it[index].code}}</label>\
<p class="mui-input-value mui-color-555">{{=it[index].name}}</p>\
</li>\
{{~}}';
/*var result = '\
{{~it:value:index}}\
<li class="mui-input-row  after_none" salerInfo={{=JSON.stringify(it[index])}}>\
<label class="mui-color-555">{{=it[index]}}</label>\
</li>\
{{~}}';*/
//var result= require('./001item.html')
var template1 = doT.template(result);


$("#MumberList").append(template1(totalData));
</script>
</html>

对象加数组===============================


<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<ul id="MumberList">

</ul>
</body>
<script src="sea.js" type="text/javascript" charset="utf-8"></script>
<script src="dot.js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script src="doT.min.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">


var totalData = {
sumary:{
QuotationNumber:1111,
cumulativePremium:'327,501.79',
quotedNumVehicles:819
},
myitem_array:[
{
contractNumbe:"20",
month:"08",
quotationNumber:"133",
realizedPremium:'222'
},
{
contractNumbe:"20",
month:"08",
quotationNumber:"133",
realizedPremium:'222'
},
{
contractNumbe:"20",
month:"08",
quotationNumber:"133",
realizedPremium:'222'
}
]
}
var result = '\
<ul>\
   <li>\
       <h3>{{=it.sumary.quotedNumVehicles}}</h3>\
       <p>累计报价车辆数</p>\
</li>\
<li>\
<h3>{{=it.sumary.cumulativePremium}}</h3>\
       <p>累计实现保费</p>\
</li>\
<li>\
<h3>{{=it.sumary.QuotationNumber}}</h3>\
       <p>报价次数</p>\
</li>\
</ul>\
<ul>\
<li><p>月份</p><p>报价数</p><p>承保数</p>\
<p>保费(元)</p>\
</li>\
{{~it.myitem_array:item:index }}\
<li class="mui-table-row">\
<p>{{=item.month}}月</p>\
<p>{{=item.quotationNumber}}</p>\
<p>{{=item.contractNumbe}}</p>\
<p>{{=item.realizedPremium}}</p>\
</li>\
{{~}}\
</ul>';

var template1 = doT.template(result);
$("#MumberList").append(template1(totalData));
</script>
</html>

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:1372367次
    • 积分:16345
    • 等级:
    • 排名:第632名
    • 原创:116篇
    • 转载:1682篇
    • 译文:0篇
    • 评论:53条
    最新评论