zoukankan      html  css  js  c++  java
  • 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);
    })
  • 相关阅读:
    随机生成密码
    vue 仿新闻项目笔记
    vuex 随笔
    SourceTree
    vue npm,Git随笔
    谷歌浏览器如何去掉自动填充的背景色
    hold 命令
    ind2vec和vec2ind函数
    稀疏矩阵(sparse matrix)
    第五篇 学习OpenCV之视频处理
  • 原文地址:https://www.cnblogs.com/jiaoyixin/p/12029390.html
Copyright © 2011-2022 走看看