抽离获取菜单js代码
parent
ba95a8e886
commit
edba8b2b10
|
|
@ -69,31 +69,9 @@
|
|||
|
||||
<script src="static/jquery.min.js"></script> <!-- 确保已经引入jQuery -->
|
||||
<script src="static/layui.js"></script>
|
||||
<script src="/static/js/menu.js"></script>
|
||||
<script src="/static/js/logout.js"></script>
|
||||
<script>
|
||||
// 请求后端获取菜单数据
|
||||
$.get('/api/menu', function (menuItems) {
|
||||
var menuList = $('.layui-nav.layui-nav-tree');
|
||||
menuList.empty();
|
||||
|
||||
menuItems.forEach(function (item) {
|
||||
var href = item.path || 'javascript:void(0);'; // 提供一个默认值
|
||||
menuList.append('<li class="layui-nav-item"><a href="' + href + '">' + item.name + '</a></li>');
|
||||
});
|
||||
|
||||
layui.element.render('nav', 'test');
|
||||
});
|
||||
|
||||
layui.use(['jquery'], function () {
|
||||
var $ = layui.jquery; // 获取Layui的jQuery对象
|
||||
|
||||
$('#logoutLink').on('click', function () {
|
||||
// 向后端发送登出请求
|
||||
$.get('/logout', function (data) {
|
||||
// 重定向到登录页面,或根据后端响应做其他处理
|
||||
window.location.href = '/login';
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -73,19 +73,9 @@
|
|||
|
||||
<script src="/static/jquery.min.js"></script> <!-- 确保已经引入jQuery -->
|
||||
<script src="/static/layui.js"></script>
|
||||
<script src="/static/js/menu.js"></script>
|
||||
<script src="/static/js/logout.js"></script>
|
||||
<script>
|
||||
// 请求后端获取菜单数据
|
||||
$.get('/api/menu', function (menuItems) {
|
||||
var menuList = $('.layui-nav.layui-nav-tree');
|
||||
menuList.empty();
|
||||
|
||||
menuItems.forEach(function (item) {
|
||||
var href = item.path || 'javascript:void(0);'; // 提供一个默认值
|
||||
menuList.append('<li class="layui-nav-item"><a href="' + href + '">' + item.name + '</a></li>');
|
||||
});
|
||||
|
||||
layui.element.render('nav', 'test');
|
||||
});
|
||||
layui.use(['laypage', 'element', 'jquery', 'dropdown'], function () {
|
||||
var laypage = layui.laypage;
|
||||
var $ = layui.jquery;
|
||||
|
|
@ -136,25 +126,6 @@
|
|||
// 初始加载第一页
|
||||
renderTable(1);
|
||||
});
|
||||
|
||||
|
||||
layui.use(['jquery'], function () {
|
||||
var laypage = layui.laypage;
|
||||
// 普通用法
|
||||
laypage.render({
|
||||
elem: 'attendance_teacher_page',
|
||||
count: 100 // 数据总数
|
||||
});
|
||||
var $ = layui.jquery; // 获取Layui的jQuery对象
|
||||
|
||||
$('#logoutLink').on('click', function () {
|
||||
// 向后端发送登出请求
|
||||
$.get('/logout', function (data) {
|
||||
// 重定向到登录页面,或根据后端响应做其他处理
|
||||
window.location.href = '/login';
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -49,19 +49,11 @@
|
|||
|
||||
<script src="static/jquery.min.js"></script> <!-- 确保已经引入jQuery -->
|
||||
<script src="static/layui.js"></script>
|
||||
<script src="/static/js/menu.js"></script>
|
||||
<script src="/static/js/logout.js"></script>
|
||||
<script>
|
||||
// 请求后端获取菜单数据
|
||||
$.get('/api/menu', function (menuItems) {
|
||||
var menuList = $('.layui-nav.layui-nav-tree');
|
||||
menuList.empty();
|
||||
|
||||
menuItems.forEach(function (item) {
|
||||
var href = item.path || 'javascript:void(0);'; // 提供一个默认值
|
||||
menuList.append('<li class="layui-nav-item"><a href="' + href + '">' + item.name + '</a></li>');
|
||||
});
|
||||
|
||||
layui.element.render('nav', 'test');
|
||||
});
|
||||
|
||||
layui.use(['table', 'jquery'], function () {
|
||||
var table = layui.table;
|
||||
|
|
@ -92,18 +84,6 @@
|
|||
});
|
||||
});
|
||||
});
|
||||
|
||||
layui.use(['jquery'], function () {
|
||||
var $ = layui.jquery; // 获取Layui的jQuery对象
|
||||
|
||||
$('#logoutLink').on('click', function () {
|
||||
// 向后端发送登出请求
|
||||
$.get('/logout', function (data) {
|
||||
// 重定向到登录页面,或根据后端响应做其他处理
|
||||
window.location.href = '/login';
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -76,20 +76,9 @@
|
|||
|
||||
<script src="static/jquery.min.js"></script> <!-- 确保已经引入jQuery -->
|
||||
<script src="static/layui.js"></script>
|
||||
<script src="/static/js/menu.js"></script>
|
||||
<script src="/static/js/logout.js"></script>
|
||||
<script>
|
||||
// 请求后端获取菜单数据
|
||||
$.get('/api/menu', function (menuItems) {
|
||||
var menuList = $('.layui-nav.layui-nav-tree');
|
||||
menuList.empty();
|
||||
|
||||
menuItems.forEach(function (item) {
|
||||
var href = item.path || 'javascript:void(0);'; // 提供一个默认值
|
||||
menuList.append('<li class="layui-nav-item"><a href="' + href + '">' + item.name + '</a></li>');
|
||||
});
|
||||
|
||||
layui.element.render('nav', 'test');
|
||||
});
|
||||
|
||||
$.get('/api/get-course-info', function (courses) {
|
||||
var tbody = $('.layui-table tbody');
|
||||
tbody.empty(); // 清空表格现有内容
|
||||
|
|
@ -104,18 +93,6 @@
|
|||
tbody.append(row); // 将新行添加到表格中
|
||||
});
|
||||
});
|
||||
|
||||
layui.use(['jquery'], function () {
|
||||
var $ = layui.jquery; // 获取Layui的jQuery对象
|
||||
|
||||
$('#logoutLink').on('click', function () {
|
||||
// 向后端发送登出请求
|
||||
$.get('/logout', function (data) {
|
||||
// 重定向到登录页面,或根据后端响应做其他处理
|
||||
window.location.href = '/login';
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -46,31 +46,9 @@
|
|||
|
||||
<script src="static/jquery.min.js"></script> <!-- 确保已经引入jQuery -->
|
||||
<script src="static/layui.js"></script>
|
||||
<script src="/static/js/menu.js"></script>
|
||||
<script src="/static/js/logout.js"></script>
|
||||
<script>
|
||||
// 请求后端获取菜单数据
|
||||
$.get('/api/menu', function (menuItems) {
|
||||
var menuList = $('.layui-nav.layui-nav-tree');
|
||||
menuList.empty();
|
||||
|
||||
menuItems.forEach(function (item) {
|
||||
var href = item.path || 'javascript:void(0);'; // 提供一个默认值
|
||||
menuList.append('<li class="layui-nav-item"><a href="' + href + '">' + item.name + '</a></li>');
|
||||
});
|
||||
|
||||
layui.element.render('nav', 'test');
|
||||
});
|
||||
|
||||
layui.use(['jquery'], function () {
|
||||
var $ = layui.jquery; // 获取Layui的jQuery对象
|
||||
|
||||
$('#logoutLink').on('click', function () {
|
||||
// 向后端发送登出请求
|
||||
$.get('/logout', function (data) {
|
||||
// 重定向到登录页面,或根据后端响应做其他处理
|
||||
window.location.href = '/login';
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -79,31 +79,9 @@
|
|||
|
||||
<script src="/static/jquery.min.js"></script> <!-- 确保已经引入jQuery -->
|
||||
<script src="/static/layui.js"></script>
|
||||
<script src="/static/js/menu.js"></script>
|
||||
<script src="/static/js/logout.js"></script>
|
||||
<script>
|
||||
// 请求后端获取菜单数据
|
||||
$.get('/api/menu', function (menuItems) {
|
||||
var menuList = $('.layui-nav.layui-nav-tree');
|
||||
menuList.empty();
|
||||
|
||||
menuItems.forEach(function (item) {
|
||||
var href = item.path || 'javascript:void(0);'; // 提供一个默认值
|
||||
menuList.append('<li class="layui-nav-item"><a href="' + href + '">' + item.name + '</a></li>');
|
||||
});
|
||||
|
||||
layui.element.render('nav', 'test');
|
||||
});
|
||||
|
||||
layui.use(['jquery'], function () {
|
||||
var $ = layui.jquery; // 获取Layui的jQuery对象
|
||||
|
||||
$('#logoutLink').on('click', function () {
|
||||
// 向后端发送登出请求
|
||||
$.get('/logout', function (data) {
|
||||
// 重定向到登录页面,或根据后端响应做其他处理
|
||||
window.location.href = '/login';
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -51,20 +51,9 @@
|
|||
|
||||
<script src="/static/jquery.min.js"></script> <!-- 确保已经引入jQuery -->
|
||||
<script src="/static/layui.js"></script>
|
||||
<script src="/static/js/menu.js"></script>
|
||||
|
||||
<script>
|
||||
|
||||
// 请求后端获取菜单数据
|
||||
$.get('/api/menu', function (menuItems) {
|
||||
var menuList = $('.layui-nav.layui-nav-tree');
|
||||
menuList.empty();
|
||||
|
||||
menuItems.forEach(function (item) {
|
||||
var href = item.path || 'javascript:void(0);'; // 提供一个默认值
|
||||
menuList.append('<li class="layui-nav-item"><a href="' + href + '">' + item.name + '</a></li>');
|
||||
});
|
||||
|
||||
layui.element.render('nav', 'test');
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
|
|
|
|||
Reference in New Issue