JS中模板嵌套学习(代码)

时间:2014-05-01 19:01:40   收藏:0   阅读:449

<script src="script/jquery-1.4.2.js"></script>
    <script src="script/jsrender.js"></script>
    <script id="header" type="text/x-jsrender">
        <tr>
               <th>序号</th>
               <th>标题</th>
               <th>图片</th>
               <th>点击次数</th>
               <th>支持</th>
               <th>反对</th>
               <th>时间</th>
               <th>操作</th>
           </tr>
    </script>
    <script id="templ" type="text/x-jsrender">
        {{include tmpl="#header" /}}
        {{for #data.photos}}
        <tr>
        <td>{{:#index+1}}</td>
        <td>{{:PTitle}}</td>
        <td>{{:PUrl}}</td>
        <td>{{:PClicks}}</td>
        <td>{{:PUp}}</td>
        <td>{{:PDown}}</td>
        <td>{{:PTime}}</td>
        <td>修改 删除</td>
        </tr>
        {{/for}}
    </script>

 

 {{include tmpl="#header" /}}中的include前不要加#,否则就是坑

模板嵌套demo网址:http://borismoore.github.io/jsrender/demos/demos.html

JS中模板嵌套学习(代码),码迷,mamicode.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!