parent
07d4dc244b
commit
813bd9ad87
3 changed files with 84 additions and 5 deletions
@ -1,11 +1,62 @@ |
||||
<template> |
||||
<div class="page-sidebar"> |
||||
<el-menu :default-active="defaultActive" router class="sidemenu" :collapse="isCollapse"> |
||||
<el-sub-menu v-for="(item,i) in treeData" :key="i" :index="item.path"> |
||||
<template #title> |
||||
<el-icon v-if="item.icon"> |
||||
<component :is="item.icon"></component> |
||||
</el-icon> |
||||
<span>{{ t(`menu.${item.name}`) }}</span> |
||||
</template> |
||||
<template v-for="(child, ci) in item.children" :key="ci"> |
||||
<el-menu-item :index="child.path"> |
||||
<el-icon> |
||||
<component :is="child.icon"></component> |
||||
</el-icon> |
||||
{{ t(`menu.${child.name}`) }} |
||||
</el-menu-item> |
||||
</template> |
||||
</el-sub-menu> |
||||
</el-menu> |
||||
</div> |
||||
</template> |
||||
|
||||
<script setup> |
||||
import {menuTreeData} from "@/mock/data.js"; |
||||
import {useRoute} from "vue-router"; |
||||
import {useI18n} from "vue-i18n"; |
||||
import {ref, computed} from "vue"; |
||||
|
||||
|
||||
const route = useRoute(); |
||||
const {t} = useI18n(); |
||||
|
||||
const treeData = menuTreeData; |
||||
const defaultActive = computed(() => route.path || treeData.value[0].path); |
||||
|
||||
const isCollapse = ref(false) |
||||
</script> |
||||
|
||||
<template> |
||||
<div>这是侧边栏组件</div> |
||||
</template> |
||||
<style lang="scss"> |
||||
$side-width: 200px; |
||||
|
||||
.page-sidebar { |
||||
.sidemenu.el-menu, |
||||
.sidemenu .el-sub-menu > .el-menu { |
||||
--el-menu-text-color: #ccc; |
||||
--el-menu-hover-bg-color: #060251; |
||||
--el-menu-border-color: transparnet; |
||||
--el-menu-bg-color: #000; |
||||
|
||||
<style scoped> |
||||
.el-menu-item { |
||||
&.is-active { |
||||
background-color: var(--el-menu-hover-bg-color); |
||||
} |
||||
} |
||||
} |
||||
.sidemenu .el-menu:not(.el-menu--colapse) { |
||||
width: $side-width; |
||||
} |
||||
} |
||||
|
||||
</style> |
||||
|
Loading…
Reference in new issue