项目中使用的artTemplate笔记

时间:2023-12-12 11:20:56

1.注意数据格式为 var results = {

  data:[

    {name:'xiaoming',age:'18'},{name:'xiaohong',age:'18'},{name:'xiaogou',age:'18'},

  ]

}

2.渲染:$('demoTpl').html(template('list'),results);   list为该script的id

3.是用原生版在赋值时应有=

demo:  <% for(var i = 0;i<data.length;i++){%>

          <h5><%=i%> <%=data[i].name%></h5>

      <%}%>

简洁版demo:{{each data as value i}}

        <h5>{{value.name}}

      {{/each}}