1 Star 0 Fork 0

cfq/foodshare-web

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
main2.html 1.47 KB
一键复制 编辑 原始数据 按行查看 历史
cfq 提交于 2022-01-06 16:17 +08:00 . C3 完成基本设计
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>后面页面</title>
<script src="./js/vue.js"></script>
<script src="./js/jquery-1.12.4.js"></script>
</head>
<body>
<div id="app">
<h1 v-if="user!=null">欢迎光临,{{user.username}} {{user.sex=='男'?'先生':'女士'}}</h1>
<h1 v-else>{{ tips }},5秒后回到登录页面</h1>
</div>
<script>
new Vue({
el: "#app",
data: {
user: null,
tips: ''
},
methods: {
},
mounted() {
let that = this;
// let params = {
// // 方法一:使用请求参数的方式传递token
// 'token': localStorage.getItem("token")
// }
$.ajax('http://localhost:8080/foodShare/admin/main.do', {
type: 'get',
dataType: 'json',
beforeSend: function (xhr) {
// 方法二:使用请求头的方式传递
xhr.setRequestHeader("Authorization", localStorage.getItem("token"))
},
success: function (res) {
if (res.code == 200) {
that.user = res.data;
return;
}
that.tips = res.msg;
setTimeout(function () {
location.href = "登录.html"
}, 5000);
}
});
}
});
</script>
</body>
</html>
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/hcbyjsal/foodshare-web.git
[email protected]:hcbyjsal/foodshare-web.git
hcbyjsal
foodshare-web
foodshare-web
master

搜索帮助