template

//引入包
<script type="text/javascript" src='../template.js'></script>
//定义一个有ID的script标签:
<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里定义模版
<script type="text/javascript">
var html = template('tem',data);
document.getElementById('mydiv').innerHTML = html;
</script>

  

 
posted @ 2016-08-05 15:49  lhy031  阅读(202)  评论(0编辑  收藏  举报