diff --git a/src/action-bar-icon/index.js b/src/action-bar-icon/index.tsx similarity index 95% rename from src/action-bar-icon/index.js rename to src/action-bar-icon/index.tsx index c3bd0e83f..a36f110af 100644 --- a/src/action-bar-icon/index.js +++ b/src/action-bar-icon/index.tsx @@ -24,6 +24,7 @@ export default createComponent({ setup(props, { slots }) { const route = useRoute(); + useParent(ACTION_BAR_KEY); const renderIcon = () => { @@ -51,7 +52,7 @@ export default createComponent({ }; return () => ( -
+
{renderIcon()} {slots.default ? slots.default() : props.text}
diff --git a/src/composition/use-relation.ts b/src/composition/use-relation.ts index a47778df6..99ff4d8d0 100644 --- a/src/composition/use-relation.ts +++ b/src/composition/use-relation.ts @@ -4,7 +4,10 @@ type Parent = { children: unknown[] }; type Child = T extends { children: (infer U)[] } ? U : never; -export function useParent

(key: string, child: Child

) { +export function useParent

( + key: string, + child = {} as Child

+) { const parent = inject

(key, null); if (parent) {