创建 menu.js

master
wangsiyuan 2023-12-28 16:34:08 +08:00
parent 756e2ca96e
commit 20bb7bd1f6
1 changed files with 11 additions and 0 deletions

11
app/static/js/menu.js Normal file
View File

@ -0,0 +1,11 @@
$.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');
});