index.vue 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <template>
  2. <el-menu default-active="1-1" class="main-menu" @open="handleOpen" @close="handleClose">
  3. <el-submenu v-for="(menu, index) of menus" :key="index" :index="String(index)">
  4. <template slot="title">
  5. <span class="menu-title" slot="title">{{menu.title}}</span>
  6. </template>
  7. <el-menu-item
  8. v-for="(sub, subIndex) of menu.subs"
  9. :key="subIndex"
  10. :index="String(index) + subIndex"
  11. @click.native="$router.push({ name: getPathName(sub) })"
  12. >{{sub.title}}</el-menu-item>
  13. <template slot="footer">
  14. <span class="menu-title" slot="title"><a target="_blank" :href="process.env.NODE_ENV === 'production' ? 'https://www.proginn.com/rooter' : 'https://dev.test.proginn.com/rooter'">{{menu.title}}</a></span>
  15. </template>
  16. </el-submenu>
  17. </el-menu>
  18. </template>
  19. <script>
  20. import data from './data'
  21. // console.log(data)
  22. let menus = data.map(menu => ({
  23. ...menu,
  24. subs: menu.subs.filter(sub => !sub.hidden)
  25. }))
  26. export default {
  27. props: [],
  28. data() {
  29. return {
  30. menus,
  31. }
  32. },
  33. mounted() {
  34. },
  35. methods: {
  36. getPathName(sub) {
  37. let name = `main-index`
  38. if(sub.path) name = `main-index-${sub.path}`
  39. return name
  40. },
  41. handleOpen() {
  42. // console.log('open')
  43. },
  44. handleClose() {
  45. // console.log('close')
  46. },
  47. },
  48. }
  49. </script>
  50. <style scoped>
  51. .menu-title {
  52. padding: 0 16px;
  53. }
  54. </style>