创建 menu.js
parent
756e2ca96e
commit
20bb7bd1f6
|
|
@ -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');
|
||||
});
|
||||
Reference in New Issue