Main.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <template>
  2. <section>
  3. <header>
  4. <div>
  5. <img src="@/assets/logo.jpg" />
  6. <ul :default-active="$route" :collapse="collapsed">
  7. <template v-for="(item,index) in menus">
  8. <li v-if="!item.hide" :key="item.desc" @click="getChildren(index)">{{item.desc}}</li>
  9. </template>
  10. </ul>
  11. </div>
  12. </header>
  13. <div id="child_menu">
  14. <div class="left">
  15. <label>行数</label>
  16. <input type="text" style="width: 40px"/>
  17. <label>确认</label>
  18. </div>
  19. <ul>
  20. <template v-for="item in child_menus">
  21. <li :key="item.desc">{{item.desc}}</li>
  22. </template>
  23. </ul>
  24. </div>
  25. <router-view>
  26. </router-view>
  27. </section>
  28. </template>
  29. <script>
  30. let data = () => {
  31. return {
  32. collapsed: false,
  33. menus: [],
  34. child_menus: []
  35. }
  36. }
  37. let initMenu = function() {
  38. for (let i in this.$router.options.routes) {
  39. let root = this.$router.options.routes[i]
  40. this.menus.push(root)
  41. }
  42. }
  43. let getChildren = function(index){
  44. this.child_menus = []
  45. for (let i in this.menus[index].children) {
  46. let root = this.menus[index].children[i]
  47. this.child_menus.push(root)
  48. }
  49. }
  50. export default {
  51. data: data,
  52. methods: {
  53. initMenu,
  54. getChildren
  55. },
  56. mounted: function() {
  57. this.initMenu()
  58. }
  59. }
  60. </script>
  61. <style scoped>
  62. header {
  63. height: 58px;
  64. background: #befae0;
  65. border-top:1px solid #00cd72;
  66. border-bottom:1px solid #00cd72;
  67. }
  68. header div{
  69. overflow: hidden;
  70. width:1200px;
  71. margin: 0 auto;
  72. }
  73. header div ul{
  74. margin: 0 auto;
  75. overflow: hidden;
  76. padding: 0;
  77. float: left;
  78. }
  79. header div img{
  80. float: left;
  81. }
  82. header div ul li{
  83. float: left;
  84. list-style: none;
  85. width: 80px;
  86. text-align: center;
  87. line-height: 58px;
  88. font-size: 14px;
  89. cursor: pointer;
  90. }
  91. .is-active{
  92. color: red;
  93. }
  94. header div ul li:nth-child(1){
  95. width: 285px;
  96. }
  97. header div ul li:nth-child(8){
  98. margin-left: 216px;
  99. }
  100. #child_menu{
  101. overflow: hidden;
  102. width: 1200px;
  103. margin: 0 auto;
  104. }
  105. #child_menu ul {
  106. margin: 5px auto;
  107. overflow: hidden;
  108. padding: 0;
  109. float: left;
  110. }
  111. #child_menu ul li{
  112. float: left;
  113. list-style: none;
  114. text-align: center;
  115. margin-left: 20px;
  116. cursor: pointer;
  117. }
  118. #child_menu .left{
  119. float: left;
  120. padding: 5px;
  121. }
  122. </style>