修改代码:permission.ts
文件位置:D:\chengchen\src\PrototypeCode\vben_client\src\store\modules\permission.ts
代码修改为:
增加动态菜单获取方法:
// 构建菜单,从后端菜单API获取数据构建菜单
buildMenusByServer() {
const menus = axios
.get('http://127.0.0.1:8000/menu/get_menu/')
.then((response) => {
const menuList = response.data;
return menuList;
})
.catch((error) => {
console.error(error);
});
menus.then((menuList) => {
// 设置菜单列表
this.setFrontMenuList(menuList);
});
},