Compare commits
No commits in common. "7e8cbf5aaaade0a4b19104edea7935a00a5d2048" and "892196a827e2423587571bb338ec5f546557b359" have entirely different histories.
7e8cbf5aaa
...
892196a827
|
|
@ -48,18 +48,20 @@
|
||||||
<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');
|
// 清空原有菜单项
|
||||||
menuList.empty();
|
var menuList = $('.layui-nav.layui-nav-tree');
|
||||||
|
menuList.empty();
|
||||||
|
|
||||||
menuItems.forEach(function (item) {
|
// 动态添加菜单项
|
||||||
var href = item.path || 'javascript:void(0);'; // 提供一个默认值
|
menuItems.forEach(function (item) {
|
||||||
menuList.append('<li class="layui-nav-item"><a href="' + href + '">' + item.name + '</a></li>');
|
menuList.append('<li class="layui-nav-item"><a href="' + item.path + '">' + 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,14 +49,16 @@
|
||||||
<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');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -49,14 +49,16 @@
|
||||||
<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.link + '">' + 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');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -49,14 +49,16 @@
|
||||||
<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');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -49,14 +49,16 @@
|
||||||
<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');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -68,8 +68,7 @@
|
||||||
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.link + '">' + 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');
|
||||||
|
|
|
||||||
Reference in New Issue