VabSubmenu.vue 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <template>
  2. <el-submenu
  3. ref="subMenu"
  4. :index="handlePath(item.path)"
  5. :popper-append-to-body="false"
  6. >
  7. <template slot="title">
  8. <vab-icon
  9. v-if="item.meta && item.meta.icon"
  10. :icon="['fas', item.meta.icon]"
  11. class="vab-fas-icon"
  12. />
  13. <vab-remix-icon
  14. v-if="item.meta && item.meta.remixIcon"
  15. :icon-class="item.meta.remixIcon"
  16. class="vab-remix-icon"
  17. />
  18. <span>{{ item.meta.title }}</span>
  19. </template>
  20. <slot />
  21. </el-submenu>
  22. </template>
  23. <script>
  24. import { isExternal } from '@/utils/validate'
  25. import path from 'path'
  26. export default {
  27. name: 'VabSubmenu',
  28. props: {
  29. routeChildren: {
  30. type: Object,
  31. default() {
  32. return null
  33. },
  34. },
  35. item: {
  36. type: Object,
  37. default() {
  38. return null
  39. },
  40. },
  41. fullPath: {
  42. type: String,
  43. default: '',
  44. },
  45. },
  46. methods: {
  47. handlePath(routePath) {
  48. if (isExternal(routePath)) {
  49. return routePath
  50. }
  51. if (isExternal(this.fullPath)) {
  52. return this.fullPath
  53. }
  54. return path.resolve(this.fullPath, routePath)
  55. },
  56. },
  57. }
  58. </script>