Compare commits
6 Commits
892196a827
...
7e8cbf5aaa
| Author | SHA1 | Date |
|---|---|---|
|
|
7e8cbf5aaa | |
|
|
eaeeba42ef | |
|
|
429e1d637c | |
|
|
8edb1cc618 | |
|
|
5387b3584b | |
|
|
26dfd131f6 |
|
|
@ -48,20 +48,18 @@
|
||||||
<script src="static/layui.js"></script>
|
<script src="static/layui.js"></script>
|
||||||
<script>
|
<script>
|
||||||
// 请求后端获取菜单数据
|
// 请求后端获取菜单数据
|
||||||
$.get('/api/menu', function (menuItems) {
|
$.get('/api/menu', function (menuItems) {
|
||||||
// 清空原有菜单项
|
var menuList = $('.layui-nav.layui-nav-tree');
|
||||||
var menuList = $('.layui-nav.layui-nav-tree');
|
menuList.empty();
|
||||||
menuList.empty();
|
|
||||||
|
|
||||||
// 动态添加菜单项
|
menuItems.forEach(function (item) {
|
||||||
menuItems.forEach(function (item) {
|
var href = item.path || 'javascript:void(0);'; // 提供一个默认值
|
||||||
menuList.append('<li class="layui-nav-item"><a href="' + item.path + '">' + item.name + '</a></li>');
|
menuList.append('<li class="layui-nav-item"><a href="' + href + '">' + item.name + '</a></li>');
|
||||||
});
|
|
||||||
|
|
||||||
// 更新菜单布局
|
|
||||||
layui.element.render('nav', 'test');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
layui.element.render('nav', 'test');
|
||||||
|
});
|
||||||
|
|
||||||
layui.use(['jquery'], function () {
|
layui.use(['jquery'], function () {
|
||||||
var $ = layui.jquery; // 获取Layui的jQuery对象
|
var $ = layui.jquery; // 获取Layui的jQuery对象
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -49,16 +49,14 @@
|
||||||
<script>
|
<script>
|
||||||
// 请求后端获取菜单数据
|
// 请求后端获取菜单数据
|
||||||
$.get('/api/menu', function (menuItems) {
|
$.get('/api/menu', function (menuItems) {
|
||||||
// 清空原有菜单项
|
|
||||||
var menuList = $('.layui-nav.layui-nav-tree');
|
var menuList = $('.layui-nav.layui-nav-tree');
|
||||||
menuList.empty();
|
menuList.empty();
|
||||||
|
|
||||||
// 动态添加菜单项
|
|
||||||
menuItems.forEach(function (item) {
|
menuItems.forEach(function (item) {
|
||||||
menuList.append('<li class="layui-nav-item"><a href="' + item.path + '">' + item.name + '</a></li>');
|
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.element.render('nav', 'test');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -49,16 +49,14 @@
|
||||||
<script>
|
<script>
|
||||||
// 请求后端获取菜单数据
|
// 请求后端获取菜单数据
|
||||||
$.get('/api/menu', function (menuItems) {
|
$.get('/api/menu', function (menuItems) {
|
||||||
// 清空原有菜单项
|
|
||||||
var menuList = $('.layui-nav.layui-nav-tree');
|
var menuList = $('.layui-nav.layui-nav-tree');
|
||||||
menuList.empty();
|
menuList.empty();
|
||||||
|
|
||||||
// 动态添加菜单项
|
|
||||||
menuItems.forEach(function (item) {
|
menuItems.forEach(function (item) {
|
||||||
menuList.append('<li class="layui-nav-item"><a href="' + item.link + '">' + item.name + '</a></li>');
|
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.element.render('nav', 'test');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -49,16 +49,14 @@
|
||||||
<script>
|
<script>
|
||||||
// 请求后端获取菜单数据
|
// 请求后端获取菜单数据
|
||||||
$.get('/api/menu', function (menuItems) {
|
$.get('/api/menu', function (menuItems) {
|
||||||
// 清空原有菜单项
|
|
||||||
var menuList = $('.layui-nav.layui-nav-tree');
|
var menuList = $('.layui-nav.layui-nav-tree');
|
||||||
menuList.empty();
|
menuList.empty();
|
||||||
|
|
||||||
// 动态添加菜单项
|
|
||||||
menuItems.forEach(function (item) {
|
menuItems.forEach(function (item) {
|
||||||
menuList.append('<li class="layui-nav-item"><a href="' + item.path + '">' + item.name + '</a></li>');
|
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.element.render('nav', 'test');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -49,16 +49,14 @@
|
||||||
<script>
|
<script>
|
||||||
// 请求后端获取菜单数据
|
// 请求后端获取菜单数据
|
||||||
$.get('/api/menu', function (menuItems) {
|
$.get('/api/menu', function (menuItems) {
|
||||||
// 清空原有菜单项
|
|
||||||
var menuList = $('.layui-nav.layui-nav-tree');
|
var menuList = $('.layui-nav.layui-nav-tree');
|
||||||
menuList.empty();
|
menuList.empty();
|
||||||
|
|
||||||
// 动态添加菜单项
|
|
||||||
menuItems.forEach(function (item) {
|
menuItems.forEach(function (item) {
|
||||||
menuList.append('<li class="layui-nav-item"><a href="' + item.path + '">' + item.name + '</a></li>');
|
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.element.render('nav', 'test');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,8 @@
|
||||||
menuList.empty();
|
menuList.empty();
|
||||||
|
|
||||||
menuItems.forEach(function (item) {
|
menuItems.forEach(function (item) {
|
||||||
menuList.append('<li class="layui-nav-item"><a href="' + item.link + '">' + item.name + '</a></li>');
|
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.element.render('nav', 'test');
|
||||||
|
|
|
||||||
Reference in New Issue