zoukankan      html  css  js  c++  java
  • 关于模板引擎使用的笔记(判断or方法调用)

    模板引擎渲染的数据必须是json格式,如果传过来的数据是嵌套数组,可以先转换:
    例如:var  b={}
                   b.c=data
     
     
     
    <script type="text/html" id="templatPlace">
    {{each Items as value indexl}}
             <p class="size">{{value.SalePart}}</p>
            {{each value.rdList as val i}}
                <table class="table table-striped table-1 place">
                    <tr>
           {{if i<3}}
                 <td class="imgOne"><img class="rowImg-1" src="./images/{{i}}.fw.png" alt=""></td>
           {{/if}}
         {{if i>=3}}
          <td class="imgOne">
               <div class='border-r border-m col-xs-1'>{{i+1}} </div>
          </td>
    {{/if}}
          <td>&nbsp;</td>
          <td class="fontSize" width="110">{{val.Director}}</td>
         <td class="fontColor">{{val.DayRate | GetHundred}}</td>
         <td class="fontColor">{{val.MonthRate | GetHundred}}</td>    //这里是模板引擎调用的方法
    </tr>
     </table>
     {{/each}}
     {{/each}}
     </script>

    <script>

    //这是模板引擎方法的书写格式

    $(function () {
    template.helper('GetHundred', function (str) {
    return ((+str) * 100).toFixed(2) + '%';
    })
    })

      

    </script>

  • 相关阅读:
    php获取http请求原文
    windows下安装MongoDB服务
    微服务RESTful 接口设计规范
    mysql主从复制原理及步骤
    nodejs主要框架
    redis事务机制和分布式锁
    计算机专业学生一定要学好这几门课
    redis常见7种使用场景
    js类型判断
    SQL语句:case when then的用法
  • 原文地址:https://www.cnblogs.com/zhuwu/p/7246244.html
Copyright © 2011-2022 走看看