art-template模板判斷


1.添加模板
<script id="userinfo" type="text/template">
          {{ if id == null }}
          <li class="login" style="white-space:nowrap;height:32px;line-height:32px;"><a href="login_f.html" >登錄</a> 
              <a  href="register.html" target="_blank">注冊</a>
              <a href="userOrder.html">我的訂單 </a> </li>
          {{ else if id != null }}
          <li class="login" style="white-space:nowrap;height:32px;line-height:32px;">
              <b>您好,歡迎您來到蘊錦IT服務平台</b> <a href="userAccount/userInfo.html" target="_blank">{{nickName}}</a> 
              <a target="_blank" onclick="logOut()">退出登錄</a>
              <a href="userOrder.html">我的訂單 </a> </li>
              {{ /if }}
        </script>
 
2.jquery獲取頁面模板並引入template到jQuery並返回到頁面
$(function(){
    var $userinfo=$('#userInfo1');
    const users=localStorage.getItem("usercurre");
    var user=JSON.parse(users);
    console.log(user)
    var html =template('userinfo',user);
    $userinfo.html(html);
})


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM