elementui侧边栏
时间: 2023-08-24 08:07:44 浏览: 100
elementui-admin 整合动态侧边栏和按钮权限控制
ElementUI侧边栏可以通过嵌套路由和菜单栏数据来实现。首先,在路由配置中,使用嵌套路由将侧边栏的各个页面嵌套在主页面的右侧展示。具体的配置可以参考如下代码段:
```javascript
const routes = [
{
path: '/main',
name: 'main',
component: () => import("@/views/main"),
redirect: "/homepage",
children: [
{ path: '/homepage', name: '系统主页', component: () => import("@/views/homepage") },
{ path: '/grade', name: '成绩管理', component: () => import("@/views/grade") },
{ path: '/information', name: '信息管理', component: () => import("@/views/information") },
{ path: '/password', name: '密码修改', component: () => import("@/views/password") },
{ path: '/course', name: '课程管理', component: () => import("@/views/course") }
]
},
];
```
然后,可以通过菜单栏数据来动态生成侧边栏的菜单项。菜单栏数据需要以嵌套的JSON数据格式进行传递,并在前端进行动态展示。具体的数据格式可以参考如下代码段:
```javascript
menuList: [
{ id: 1, parentid: '0', name: '系统主页', icon: 'HomeFilled', url: '/homepage' },
{
id: 2, parentid: '0', name: '学生管理', icon: 'UserFilled',
children: [
{
id: 3, parentid: '2', name: '信息管理', icon: '',
children: [
{ id: 4, parentid: '2', name: '密码修改', icon: '', url: '/password' }
]
},
{ id: 5, parentid: '2', name: '成绩管理', icon: '', url: '/grade' }
]
},
{ id: 6, parentid: '0', name: '课程管理', icon: 'List', url: '/course' }
]
```
通过这样的配置,你可以使用ElementUI的组件来实现侧边栏的功能,同时根据菜单栏数据来动态生成菜单项。这样用户就可以通过点击菜单项来切换不同的页面了。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [Vue+ELementUI主页布局----侧边栏布局(el-aside)](https://blog.csdn.net/weixin_51351637/article/details/127129259)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
- *2* *3* [element ui实现动态侧边菜单栏以及页面布局](https://blog.csdn.net/zhanglinsen123/article/details/125837825)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文