Aside.vue 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <template>
  2. <el-menu
  3. :default-active="this.$store.state.currentMenuItem"
  4. style="width: 220px; height: 100%"
  5. background-color="#141B29"
  6. text-color="#fff"
  7. active-text-color="#ffd04b"
  8. :router="true"
  9. >
  10. <el-sub-menu v-for="(item, index) in menu" :key="item" :index="`${index}`">
  11. <template v-slot:title>
  12. <i :class="item.icon"></i>
  13. <span>{{ item.title }}</span>
  14. </template>
  15. <el-menu-item
  16. v-for="son in item.items"
  17. :index="son.path"
  18. :key="son"
  19. @click="changeIndex(son.path)"
  20. >
  21. {{ son.name }}
  22. </el-menu-item>
  23. </el-sub-menu>
  24. </el-menu>
  25. </template>
  26. <script>
  27. import { ref } from "vue";
  28. export default {
  29. setup() {
  30. let defaultActive = ref();
  31. function changeIndex(path) {
  32. defaultActive.value = path;
  33. }
  34. let menu = [
  35. {
  36. icon: "el-icon-s-data",
  37. title: "航次",
  38. items: [
  39. {
  40. path: "/voyage/voyageList",
  41. name: "航次列表",
  42. },
  43. ],
  44. },
  45. ];
  46. return {
  47. changeIndex,
  48. defaultActive,
  49. menu,
  50. };
  51. },
  52. };
  53. </script>