zoukankan      html  css  js  c++  java
  • art-template使用

    1. 渲染单个对象数据

      1. 回调函数中设置渲染对象

    const stionStr = template("script的id", {list: ele});
    $(".info").html(stionStr);
    

      2. 在script中定义模板

    <script type="text/html" id="topboxInfo" >
            <h6 class="title">{{ list.name}}</h6>
            <div class="fz">直流桩:6    直流桩:6</div>
            <div class="sm">
                <span class="kx"><em>空闲:</em><i>{{ list.stat.idle }}</i><i>/</i>{{list.stat.total}}</span>
                <span class="kx fr"><em>故障:</em><i>0</i></span>
            </div>
            <div class="box">
                <li class="address">{{list.address}}</li>
                <li class="tel">0571-88668630</li>
                <li class="time">周一至周日 24:00-00:00</li>
            </div>   
        </script>
    

    2. 遍历数组

      

    const htmlStrT = template("botboxList", {list : res.chargers});
    $(".botbox .list").html(htmlStrT);
    

      

    {{ each list curr index }}
            <li>
                <h6 class="title">{{curr.name}}</h6>
                <div class="fz">地址:{{curr.address}}</div>
            </li>
    {{ /each }}
    

      

  • 相关阅读:
    Windows下载Vim
    分享:分享几个程序员使用的网站
    分享:C语言大礼包(PDF)
    将vscode打造成强大的C/C++ IDE
    最适合做C/C++开发的IDE
    bzoj 2244
    bzoj 1492
    bzoj 3262
    bzoj 1176
    bzoj 2961
  • 原文地址:https://www.cnblogs.com/xhrr/p/11224040.html
Copyright © 2011-2022 走看看