Layout.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <template>
  2. <a-layout id="components-layout-demo-responsive">
  3. <a-layout-sider
  4. v-model="collapsed"
  5. theme="dark"
  6. >
  7. <div class="logo"></div>
  8. <a-menu class="menu-item" theme="dark" mode="inline" @click="menuHandle" :default-selected-keys="['menu_1']">
  9. <a-menu-item :key="index" v-for="(menuInfo, index) in menu" :title="menuInfo.title">
  10. <a-icon :type="menuInfo.icon" />
  11. </a-menu-item>
  12. </a-menu>
  13. </a-layout-sider>
  14. <a-layout>
  15. <a-layout-sider
  16. theme="light"
  17. >
  18. <a-menu class="sub-menu-item" theme="light" mode="inline" v-model="subMenuKey" :default-selected-keys="subMenuKey">
  19. <a-menu-item :key="subIndex" v-for="(menuInfo, subIndex) in subMenu">
  20. <span class="nav-text">{{ menuInfo.title }}</span>
  21. </a-menu-item>
  22. </a-menu>
  23. </a-layout-sider>
  24. <a-layout-content :style="{ margin: '24px 16px 0' }">
  25. <div :style="{ padding: '24px', background: '#fff', minHeight: '360px' }">
  26. content
  27. </div>
  28. </a-layout-content>
  29. </a-layout>
  30. </a-layout>
  31. </template>
  32. <script>
  33. export default {
  34. name: 'Layout',
  35. data() {
  36. return {
  37. collapsed: true,
  38. menu: {
  39. 'menu_1' : {
  40. icon: 'home',
  41. title: ''
  42. },
  43. 'menu_2' : {
  44. icon: 'setting',
  45. title: ''
  46. },
  47. },
  48. menuKey: 'menu_1',
  49. subMenuKey: ['subMenu_1'],
  50. subMenu: {},
  51. subMenuList: {
  52. 'menu_1' : {
  53. 'subMenu_1' : {
  54. title: 'home菜单1',
  55. page: ''
  56. },
  57. 'subMenu_2' : {
  58. title: 'home菜单2',
  59. page: ''
  60. },
  61. },
  62. 'menu_2' : {
  63. 'subMenu_1' : {
  64. title: 'setting菜单1',
  65. page: ''
  66. },
  67. 'subMenu_2' : {
  68. title: 'setting菜单2',
  69. page: ''
  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. },
  84. subMenuHandle (index) {
  85. console.log('sub menu key:', index)
  86. }
  87. },
  88. };
  89. </script>
  90. <style lang="less" scoped>
  91. #components-layout-demo-responsive .logo {
  92. height: 32px;
  93. background: rgba(139, 137, 137, 0.2);
  94. margin: 16px;
  95. }
  96. #components-layout-demo-responsive .menu-item .ant-menu-item {
  97. background-color: #001529;
  98. }
  99. #components-layout-demo-responsive .sub-menu-item .ant-menu-item::after {
  100. border-right: 3px solid #F2F2F2;
  101. }
  102. #components-layout-demo-responsive .sub-menu-item .ant-menu-item-selected {
  103. background-color:#F2F2F2;
  104. span {
  105. color: #111;
  106. }
  107. }
  108. // /deep/ .ant-menu-item a {
  109. // color:rgba(255, 255, 255, 0.15);
  110. // }
  111. </style>