DemoMenu.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <template>
  2. <a-layout id="app-demo-menu">
  3. <a-layout-sider
  4. theme="light"
  5. class="layout-sider"
  6. >
  7. <a-menu theme="light" mode="inline" :default-selected-keys="['menu_100']">
  8. <a-menu-item v-for="(menuInfo, subIndex) in menu" :key="subIndex">
  9. <router-link :to="{ name: menuInfo.pageName, params: menuInfo.params}">
  10. <span>{{ menuInfo.title }}</span>
  11. </router-link>
  12. </a-menu-item>
  13. </a-menu>
  14. </a-layout-sider>
  15. <a-layout>
  16. <a-layout-content>
  17. <router-view />
  18. </a-layout-content>
  19. </a-layout>
  20. </a-layout>
  21. </template>
  22. <script>
  23. export default {
  24. data() {
  25. return {
  26. menu: {
  27. 'menu_100' : {
  28. icon: 'profile',
  29. title: '文件',
  30. pageName: 'DemoFileIndex',
  31. params: {}
  32. },
  33. 'menu_300' : {
  34. icon: 'profile',
  35. title: '通信',
  36. pageName: 'DemoSocketIndex',
  37. params: {}
  38. },
  39. 'menu_400' : {
  40. icon: 'profile',
  41. title: '视图',
  42. pageName: 'DemoWindowViewIndex',
  43. params: {}
  44. },
  45. 'menu_401' : {
  46. icon: 'profile',
  47. title: '窗口',
  48. pageName: 'DemoWindowIndex',
  49. params: {}
  50. },
  51. 'menu_500' : {
  52. icon: 'profile',
  53. title: '软件',
  54. pageName: 'DemoSoftwareIndex',
  55. params: {}
  56. },
  57. 'menu_600' : {
  58. icon: 'profile',
  59. title: '系统',
  60. pageName: 'DemoSystemIndex',
  61. params: {}
  62. },
  63. 'menu_800' : {
  64. icon: 'profile',
  65. title: '快捷键',
  66. pageName: 'DemoShortcutIndex',
  67. params: {}
  68. },
  69. 'menu_900' : {
  70. icon: 'profile',
  71. title: '测试',
  72. pageName: 'DemoTestApiIndex',
  73. params: {}
  74. }
  75. }
  76. };
  77. },
  78. created () {
  79. },
  80. mounted () {
  81. this.menuHandle({key: 'menu_100'})
  82. },
  83. methods: {
  84. menuHandle (item) {
  85. const linkInfo = this.menu[item.key]
  86. this.$router.push({ name: linkInfo.pageName, params: linkInfo.params})
  87. }
  88. }
  89. };
  90. </script>
  91. <style lang="less" scoped>
  92. #app-demo-menu {
  93. height: 100%;
  94. text-align: center;
  95. .layout-sider {
  96. border-top: 1px solid #e8e8e8;
  97. border-right: 1px solid #e8e8e8;
  98. background-color: #FAFAFA;
  99. overflow: auto;
  100. }
  101. }
  102. </style>