art-template模板判断
2024-08-29 19:31:12
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);
})
最新文章
- 网站美化常见CSS
- BackTrack5-r3任务栏显示网络图标及自定义DNS
- Spark Streaming源码解读之No Receivers彻底思考
- 未能加载文件或程序集&ldquo;System.Web.Http.WebHost, Version=4.0.0.0, &rdquo;或它的某一个依赖项。系统找不到指定的文件。
- android oncreate获取宽高度
- UVALive 5888 Stack Machine Executor (栈+模拟)
- SQL_转换格式的函数—CAST()和CONVERT()
- tomcat 系统架构与设计模式 第二部分 设计模式 转
- javabean 简介
- [转] JSON for java入门总结
- 简单竖向Tab选项卡
- Eclipse用法和技巧三:自动生成Main方法2
- Cordic 算法之 反正切
- EF Code First、DbContext
- Ajax原理、优缺点及应用场景
- 【linux之设备,分区,文件系统】
- 问题7:JavaScript 常用正则示例
- [转][html]设置IIS 默认页
- ubuntu下安装php
- spring data redis的配置类RedisConfig
热门文章
- 启动Spring Tool Suite 4时出现 could not find tools.jar spring boot live hovers....弹窗
- vue 前端处理监听关键字搜索
- Idea集成SpringBoot实现两种热部署方式(亲测有效)
- C#winfrom文件下载到本地
- 【SSM Spring 线程池 OJ】 使用Spring线程池ThreadPoolTaskExecutor
- Elasticsearch系列---简单入门实战
- jQuery学习笔记3
- Java基础IO类之字节输入输出流
- python网络爬虫之自动化测试工具selenium[二]
- Ansible Playbooks 介绍 和 使用 一