index.vue 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <template>
  2. <div class="siderBar">
  3. <el-row class="tac">
  4. <el-col>
  5. <el-menu
  6. default-active="2"
  7. class="el-menu-vertical-demo"
  8. @open="handleOpen"
  9. @close="handleClose">
  10. <template v-for="(item,index) in menu">
  11. <el-submenu v-if="item.children.length" :index="String(index)" :key="index">
  12. <template slot="title">
  13. <span>{{item.MenuName}}</span>
  14. </template>
  15. <el-menu-item-group>
  16. <el-menu-item v-for="(subItem,subIndex) in item.children" :key="subIndex" :index="String(index)+'-'+String(subIndex)">
  17. <router-link :to="{name:subItem.Url,query:{}}" active-class="active">{{subItem.MenuName}}</router-link>
  18. </el-menu-item>
  19. </el-menu-item-group>
  20. </el-submenu>
  21. <el-menu-item v-else :index="String(index)" :key="index">
  22. <span slot="title">{{item.MenuName}}</span>
  23. </el-menu-item>
  24. </template>
  25. </el-menu>
  26. </el-col>
  27. </el-row>
  28. </div>
  29. </template>
  30. <script>
  31. export default {
  32. name: '',
  33. props: ['menu'],
  34. data () {
  35. return {
  36. }
  37. },
  38. mounted () {
  39. this.$nextTick(function () {
  40. // console.log(this.menu)
  41. })
  42. },
  43. methods: {
  44. handleOpen (key, keyPath) {
  45. // console.log(key, keyPath)
  46. },
  47. handleClose (key, keyPath) {
  48. // console.log(key, keyPath)
  49. }
  50. }
  51. }
  52. </script>
  53. <!-- Add "scoped" attribute to limit CSS to this component only -->
  54. <style lang="scss" scoped>
  55. @import "page.scss";
  56. </style>