更新 announcement.html
parent
892196a827
commit
26dfd131f6
|
|
@ -48,20 +48,18 @@
|
|||
<script src="static/layui.js"></script>
|
||||
<script>
|
||||
// 请求后端获取菜单数据
|
||||
$.get('/api/menu', function (menuItems) {
|
||||
// 清空原有菜单项
|
||||
var menuList = $('.layui-nav.layui-nav-tree');
|
||||
menuList.empty();
|
||||
$.get('/api/menu', function (menuItems) {
|
||||
var menuList = $('.layui-nav.layui-nav-tree');
|
||||
menuList.empty();
|
||||
|
||||
// 动态添加菜单项
|
||||
menuItems.forEach(function (item) {
|
||||
menuList.append('<li class="layui-nav-item"><a href="' + item.path + '">' + item.name + '</a></li>');
|
||||
});
|
||||
|
||||
// 更新菜单布局
|
||||
layui.element.render('nav', 'test');
|
||||
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对象
|
||||
|
||||
|
|
|
|||
Reference in New Issue