template

//引入包
1
<script type="text/javascript" src='../template.js'></script>
//定义一个有ID的script标签:
1
2
3
4
5
6
7
8
9
10
11
12
<script id='tem' type="text/html">
<h4>{{name}}</h4>
<ul>
{{each films as value}}
<li>
<strong>电影名称:</strong>{{value.title}}<br>
<strong style='color:red'>导演</strong>{{value.lead}}<br>
<strong style='color:green'>主演:</strong>{{value.role}}
</li>
{{/each}}
</ul>
</script>
//在另一个script里定义模版
1
2
3
4
<script type="text/javascript">
var html = template('tem',data);
document.getElementById('mydiv').innerHTML = html;
</script>

  

 
posted @   lhy031  阅读(202)  评论(0编辑  收藏  举报
努力加载评论中...
点击右上角即可分享
微信分享提示