feat(@vant/use): useParent always return index (#8120)

This commit is contained in:
neverland
2021-02-10 11:03:36 +08:00
committed by GitHub
parent faab7c03f0
commit 4ba646f2b6

View File

@@ -1,4 +1,5 @@
import {
ref,
inject,
computed,
onUnmounted,
@@ -18,9 +19,7 @@ export function useParent<T>(key: string | symbol) {
const parent = inject<ParentProvide<T> | null>(key, null);
if (parent) {
const instance = getCurrentInstance();
if (instance) {
const instance = getCurrentInstance()!;
const { link, unlink, internalChildren, ...rest } = parent;
link(instance);
@@ -36,7 +35,9 @@ export function useParent<T>(key: string | symbol) {
index,
};
}
}
return {};
return {
parent: null,
index: ref(-1),
};
}