aside.vue 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <template>
  2. <div class="aside">
  3. <el-menu
  4. default-active="1"
  5. class="el-menu-vertical"
  6. :collapse="isCollapse"
  7. @open="handleOpen"
  8. @close="handleClose"
  9. background-color="#f1f2f2"
  10. active-text-color="#EB786D"
  11. >
  12. <el-sub-menu index="1">
  13. <template #title>
  14. <el-icon><location /></el-icon>
  15. <span>Navigator One</span>
  16. </template>
  17. <el-menu-item-group>
  18. <template #title><span>Group One</span></template>
  19. <el-menu-item index="1-1">item one</el-menu-item>
  20. <el-menu-item index="1-2">item two</el-menu-item>
  21. </el-menu-item-group>
  22. <el-menu-item-group title="Group Two">
  23. <el-menu-item index="1-3">item three</el-menu-item>
  24. </el-menu-item-group>
  25. <el-sub-menu index="1-4">
  26. <template #title><span>item four</span></template>
  27. <el-menu-item index="1-4-1">item one</el-menu-item>
  28. </el-sub-menu>
  29. </el-sub-menu>
  30. <el-menu-item index="2">
  31. <el-icon><icon-menu /></el-icon>
  32. <template #title>Navigator Two</template>
  33. </el-menu-item>
  34. <el-menu-item index="3">
  35. <el-icon><document /></el-icon>
  36. <template #title>Navigator Three</template>
  37. </el-menu-item>
  38. <el-menu-item index="4">
  39. <el-icon><setting /></el-icon>
  40. <template #title>Navigator Four</template>
  41. </el-menu-item>
  42. </el-menu>
  43. </div>
  44. </template>
  45. <script setup>
  46. import { ref } from "vue";
  47. const isCollapse = ref(true);
  48. const handleOpen = (key, keyPath) => {
  49. console.log(key, keyPath);
  50. };
  51. const handleClose = (key, keyPath) => {
  52. console.log(key, keyPath);
  53. };
  54. </script>
  55. <style lang="scss" scoped>
  56. .aside {
  57. width: 74px;
  58. height: calc(100% - 40px);
  59. background: #f1f2f2;
  60. box-shadow: 0px 2px 4px 0px rgba(0, 0, 0, 0.25);
  61. border-radius: 8px;
  62. box-sizing: border-box;
  63. .el-menu--vertical {
  64. --el-menu-vertical-height: 100%;
  65. border-radius: 8px 8px 0 0;
  66. width: 100%;
  67. margin: 20px 0;
  68. }
  69. .el-menu {
  70. border-right: none;
  71. }
  72. }
  73. </style>