@@ -9,15 +9,13 @@ interface Props {
99 basePath? : string
1010}
1111
12- const props = withDefaults (defineProps <Props >(), {
13- basePath: " "
14- })
12+ const { item, basePath = " " } = defineProps <Props >()
1513
1614/** 是否始终显示根菜单 */
17- const alwaysShowRootMenu = computed (() => props . item .meta ?.alwaysShow )
15+ const alwaysShowRootMenu = computed (() => item .meta ?.alwaysShow )
1816
1917/** 显示的子菜单 */
20- const showingChildren = computed (() => props . item .children ?.filter (child => ! child .meta ?.hidden ) ?? [])
18+ const showingChildren = computed (() => item .children ?.filter (child => ! child .meta ?.hidden ) ?? [])
2119
2220/** 显示的子菜单数量 */
2321const showingChildNumber = computed (() => showingChildren .value .length )
@@ -31,7 +29,7 @@ const theOnlyOneChild = computed(() => {
3129 case number === 1 :
3230 return showingChildren .value [0 ]
3331 default :
34- return { ... props . item , path: " " }
32+ return { ... item , path: " " }
3533 }
3634})
3735
@@ -40,10 +38,10 @@ function resolvePath(routePath: string) {
4038 switch (true ) {
4139 case isExternal (routePath ):
4240 return routePath
43- case isExternal (props . basePath ):
44- return props . basePath
41+ case isExternal (basePath ):
42+ return basePath
4543 default :
46- return path .resolve (props . basePath , routePath )
44+ return path .resolve (basePath , routePath )
4745 }
4846}
4947 </script >
@@ -60,13 +58,13 @@ function resolvePath(routePath: string) {
6058 </el-menu-item >
6159 </Link >
6260 </template >
63- <el-sub-menu v-else :index =" resolvePath(props. item.path)" teleported >
61+ <el-sub-menu v-else :index =" resolvePath(item.path)" teleported >
6462 <template #title >
65- <SvgIcon v-if =" props. item.meta?.svgIcon" :name =" props. item.meta.svgIcon" class =" svg-icon" />
66- <component v-else-if =" props. item.meta?.elIcon" :is =" props. item.meta.elIcon" class =" el-icon" />
67- <span v-if =" props. item.meta?.title" class =" title" >{{ props. item.meta.title }}</span >
63+ <SvgIcon v-if =" item.meta?.svgIcon" :name =" item.meta.svgIcon" class =" svg-icon" />
64+ <component v-else-if =" item.meta?.elIcon" :is =" item.meta.elIcon" class =" el-icon" />
65+ <span v-if =" item.meta?.title" class =" title" >{{ item.meta.title }}</span >
6866 </template >
69- <template v-if =" props . item .children " >
67+ <template v-if =" item .children " >
7068 <Item
7169 v-for =" child in showingChildren"
7270 :key =" child.path"
0 commit comments