HomeAside.vue 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <script>
  2. import menuList from '@/data/json/menuList.json'
  3. export default {
  4. props: {
  5. collapse: Boolean,
  6. },
  7. data() {
  8. return {
  9. asideStyle: {},
  10. menuList,
  11. }
  12. },
  13. watch: {
  14. collapse(val) {
  15. this.suitHeight(val)
  16. },
  17. },
  18. mounted() {
  19. this.suitHeight(this.collapse)
  20. },
  21. methods: {
  22. suitHeight(val) {
  23. this.$nextTick(() => {
  24. let height = document.getElementsByClassName('home')[0].clientHeight
  25. this.asideStyle = { height: `${height - 60}px` }
  26. if (val)
  27. this.asideStyle.width = '60px'
  28. })
  29. },
  30. handleSelected(item) {
  31. //this.$router.push({name: item.key})
  32. if (item.key=='nav') {
  33. this.$router.push({name: 'nav'})
  34. } else {
  35. console.log(item.key)
  36. console.log(item && item.key!='')
  37. if (item && item.key!=='') {
  38. let obj = this.menuList[item.key]
  39. console.log(obj)
  40. this.$router.push({path: obj.router})
  41. } else {
  42. this.$router.push({name: 'empty'})
  43. }
  44. }
  45. },
  46. },
  47. }
  48. </script>
  49. <template>
  50. <div class="aside">
  51. <a-menu
  52. class="menu"
  53. theme="dark"
  54. :style="asideStyle"
  55. :default-selected-keys="['1']"
  56. mode="inline"
  57. @select="handleSelected"
  58. >
  59. <a-menu-item v-for="(item,index) in menuList" :key="index" :route="item.key">
  60. <span class="anticon"><i-icon-park-outline-more-app /></span>
  61. <span>
  62. {{ item.name }}
  63. </span>
  64. </a-menu-item>
  65. </a-menu>
  66. </div>
  67. </template>
  68. <style lang="less" scoped>
  69. .aside {
  70. //width: 100%;
  71. height: 100%;
  72. /deep/ .ant-menu-sub {
  73. box-shadow: none !important;
  74. }
  75. /deep/ .ant-menu-item-selected {
  76. color: @menu-dark-selected-item-text-color !important;
  77. }
  78. .ant-menu-inline-collapsed > .ant-menu-item {
  79. padding: 0 !important;
  80. margin-left: 0 !important;
  81. padding-left: 33% !important;
  82. }
  83. /deep/ .ant-menu-inline-collapsed > .ant-menu-item-group > .ant-menu-item-group-list > .ant-menu-item {
  84. padding: 0 !important;
  85. margin-left: 0 !important;
  86. padding-left: 33% !important;
  87. }
  88. }
  89. </style>