MenuItem.vue 786 B

123456789101112131415161718192021222324252627282930313233
  1. <template>
  2. <el-menu-item :index="subItem.path" @click="handleClickMenu(subItem)">
  3. <el-icon>
  4. <component :is="subItem?.meta?.icon"></component>
  5. </el-icon>
  6. <template #title>
  7. <span>{{ subItem?.meta?.title }}</span>
  8. </template>
  9. </el-menu-item>
  10. </template>
  11. <script setup lang="ts">
  12. import { ref } from 'vue'
  13. import { useRouter } from 'vue-router'
  14. import { isExternal } from '@/utils/validate'
  15. const router = useRouter()
  16. let props = defineProps({
  17. menuList: {
  18. type: Array,
  19. default: () => [],
  20. },
  21. subItem: {
  22. type: Object,
  23. default: () => {},
  24. },
  25. })
  26. const handleClickMenu = (subItem) => {
  27. if (isExternal(subItem.path)) return window.open(subItem.path, '_blank')
  28. router.push(subItem.path)
  29. }
  30. </script>