mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-24 02:16:12 +08:00
refactor: remove useChildren
This commit is contained in:
parent
b463fa5f69
commit
e893efd60d
@ -1,5 +1,5 @@
|
||||
import { ref, provide } from 'vue';
|
||||
import { createNamespace } from '../utils';
|
||||
import { useChildren } from '../api/use-relation';
|
||||
|
||||
const [createComponent, bem] = createNamespace('action-bar');
|
||||
|
||||
@ -14,7 +14,8 @@ export default createComponent({
|
||||
},
|
||||
|
||||
setup(props, { slots }) {
|
||||
useChildren(ACTION_BAR_KEY);
|
||||
const children = ref([]);
|
||||
provide(ACTION_BAR_KEY, children);
|
||||
|
||||
return () => (
|
||||
<div class={bem({ unfit: !props.safeAreaInsetBottom })}>
|
||||
|
@ -1,15 +1,9 @@
|
||||
import { ref, Ref, provide, inject, computed, onUnmounted } from 'vue';
|
||||
import { Ref, inject, computed, onUnmounted } from 'vue';
|
||||
|
||||
export type Parent<T = unknown> = null | {
|
||||
children: Ref<Ref<T>[]>;
|
||||
};
|
||||
|
||||
export function useChildren(key: string) {
|
||||
const children = ref<unknown>([]);
|
||||
provide(key, { children });
|
||||
return children;
|
||||
}
|
||||
|
||||
export function useParent<T = unknown>(key: string, child: Ref<T>) {
|
||||
const parent = inject<Parent<T>>(key, null);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user