Layout.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <template>
  2. <a-layout id="components-layout-demo-responsive">
  3. <a-layout-sider
  4. v-model="collapsed"
  5. theme="light"
  6. class="layout-sider"
  7. >
  8. <div class="logo"><img class="pic-logo" src="~@/assets/logo.png"></div>
  9. <a-menu class="menu-item" theme="light" mode="inline" @click="menuHandle" :default-selected-keys="['menu_1']">
  10. <a-menu-item :key="index" v-for="(menuInfo, index) in menu" :title="menuInfo.title">
  11. <a-icon :type="menuInfo.icon" />
  12. </a-menu-item>
  13. </a-menu>
  14. </a-layout-sider>
  15. <a-layout>
  16. <a-layout-sider
  17. theme="light"
  18. class="sub-layout-sider"
  19. >
  20. <a-menu class="sub-menu-item" theme="light" mode="inline" v-model="subMenuKey" :default-selected-keys="subMenuKey">
  21. <a-menu-item :key="subIndex" v-for="(menuInfo, subIndex) in subMenu">
  22. <router-link :to="{ path: menuInfo.page }">
  23. <span>{{ menuInfo.title }}</span>
  24. </router-link>
  25. </a-menu-item>
  26. </a-menu>
  27. </a-layout-sider>
  28. <a-layout-content :style="{}">
  29. <div :style="{ padding: '24px', background: '#fff', minHeight: '560px' }">
  30. <router-view />
  31. </div>
  32. </a-layout-content>
  33. </a-layout>
  34. </a-layout>
  35. </template>
  36. <script>
  37. export default {
  38. name: 'Layout',
  39. data() {
  40. return {
  41. collapsed: true,
  42. menu: {
  43. 'menu_1' : {
  44. icon: 'home',
  45. title: ''
  46. },
  47. 'menu_2' : {
  48. icon: 'setting',
  49. title: ''
  50. },
  51. },
  52. menuKey: 'menu_1',
  53. subMenuKey: ['subMenu_1'],
  54. subMenu: {},
  55. subMenuList: {
  56. 'menu_1' : {
  57. 'subMenu_1' : {
  58. title: '打开文件夹',
  59. page: '/file/openDir'
  60. }
  61. },
  62. 'menu_2' : {
  63. 'subMenu_1' : {
  64. title: '设置菜单1',
  65. page: '/testc/testc'
  66. },
  67. 'subMenu_2' : {
  68. title: '设置菜单2',
  69. page: '/testd'
  70. },
  71. },
  72. },
  73. contentPage: ''
  74. };
  75. },
  76. mounted () {
  77. this.menuHandle({key: 'menu_1'})
  78. },
  79. methods: {
  80. menuHandle (item) {
  81. this.subMenu = this.subMenuList[item.key]
  82. this.subMenuKey = ['subMenu_1']
  83. const linkPage = this.subMenu['subMenu_1']['page']
  84. this.$router.push(linkPage)
  85. },
  86. },
  87. };
  88. </script>
  89. <style lang="less" scoped>
  90. // 嵌套
  91. #components-layout-demo-responsive {
  92. .logo {
  93. border-bottom: 1px solid #e8e8e8;
  94. }
  95. .pic-logo {
  96. height: 32px;
  97. //background: rgba(139, 137, 137, 0.2);
  98. margin: 10px;
  99. }
  100. .layout-sider {
  101. border-right: 1px solid #e8e8e8;
  102. }
  103. .menu-item {
  104. .ant-menu-item {
  105. background-color: #fff;
  106. margin-top: 0px;
  107. margin-bottom: 0px;
  108. }
  109. }
  110. .sub-layout-sider {
  111. background-color: #FAFAFA;
  112. }
  113. .sub-menu-item {
  114. .ant-menu-item {
  115. margin-top: 0px;
  116. margin-bottom: 0px;
  117. }
  118. .ant-menu-item::after {
  119. border-right: 3px solid #F2F2F2;
  120. }
  121. .ant-menu-item-selected {
  122. background-color:#F2F2F2;
  123. span {
  124. color: #111;
  125. }
  126. }
  127. }
  128. .sub-menu-item.ant-menu {
  129. background: #FAFAFA;
  130. }
  131. .sub-menu-item.ant-menu-inline {
  132. border-right: 0px solid #FAFAFA;
  133. }
  134. }
  135. // #components-layout-demo-responsive .logo {
  136. // height: 32px;
  137. // background: rgba(139, 137, 137, 0.2);
  138. // margin: 16px;
  139. // }
  140. // #components-layout-demo-responsive .menu-item .ant-menu-item {
  141. // background-color: #001529;
  142. // margin-top: 0px;
  143. // margin-bottom: 0px;
  144. // }
  145. // #components-layout-demo-responsive .sub-menu-item .ant-menu-item {
  146. // margin-top: 0px;
  147. // margin-bottom: 0px;
  148. // }
  149. // #components-layout-demo-responsive .sub-menu-item .ant-menu-item::after {
  150. // border-right: 3px solid #F2F2F2;
  151. // }
  152. // #components-layout-demo-responsive .sub-menu-item.ant-menu {
  153. // background: #FAFAFA;
  154. // }
  155. // #components-layout-demo-responsive .sub-menu-item.ant-menu-inline {
  156. // border-right: 0px solid #FAFAFA;
  157. // }
  158. // #components-layout-demo-responsive .sub-menu-item .ant-menu-item-selected {
  159. // background-color:#F2F2F2;
  160. // span {
  161. // color: #111;
  162. // }
  163. // }
  164. </style>