var data = {
    list : [{
        title : 'xxx1',
        tags : ['文艺1', '博客1', '摄影1', '电影1']
    },
    {
        title : 'xxx2',
        tags : ['文艺2', '博客2', '摄影2', '电影2']
    }]
}
var html = template('test', data)
document.getElementById('content').innerHTML = html;
模板部分
<script > {{if isAdmin}} {{each list as item i}} <h1>{{item.title}}</h1> <ul> {{each item.tags as tag i}} <li>索引 {{i + 1}} :{{tag}}</li> {{/each}} </ul> {{/each}} {{/if}} </script> bug fix for (d in data) { // alert(JSON.stringify(data[d])) var html = template('test', data[d]); } document.getElementById('content').innerHTML = html; html 代表的是最后一组数据的html

相关文章:

  • 2021-05-17
  • 2022-12-23
  • 2022-12-23
  • 2022-02-25
  • 2022-02-03
  • 2021-06-30
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-12-26
  • 2022-12-23
  • 2021-08-23
  • 2021-11-24
  • 2022-12-23
  • 2022-12-23
  • 2021-05-04
相关资源
相似解决方案