(key) as ChildrenCounter
+
const { collect, clear, instances } = childrenCounter
const instance: ComponentInternalInstance = getCurrentInstance() as ComponentInternalInstance
@@ -191,15 +190,15 @@ export function useChildren(key: symbol) {
}
export function useParent
(key: symbol) {
- const rawParentProvider = inject
>(key) as P & BaseParentProvider
-
- if (!rawParentProvider) {
+ if (!keyInProvides(key)) {
return {
parentProvider: null,
bindParent: null,
}
}
+ const rawParentProvider = inject>(key) as P & BaseParentProvider
+
const { collect, clear, ...parentProvider } = rawParentProvider
const bindParent = (childProvider: C) => {
@@ -212,3 +211,9 @@ export function useParent(key: symbol) {
bindParent,
}
}
+
+export function keyInProvides(key: symbol) {
+ const instance = getCurrentInstance() as any
+
+ return Object.prototype.hasOwnProperty.call(instance.provides, key)
+}
diff --git a/packages/varlet-ui/src/utils/shared.ts b/packages/varlet-ui/src/utils/shared.ts
index 50c08b306dc..efceec5e047 100644
--- a/packages/varlet-ui/src/utils/shared.ts
+++ b/packages/varlet-ui/src/utils/shared.ts
@@ -19,7 +19,8 @@ export const isArray = (val: unknown): val is Array => Array.isArray(val)
export const isURL = (val: string) => /^(http)|(\.*\/)/.test(val)
-export const isEmpty = (val: unknown) => val === undefined || val === null || val === ''
+export const isEmpty = (val: unknown) =>
+ val === undefined || val === null || val === '' || (Array.isArray(val) && !val.length)
export const removeItem = (arr: Array, item: unknown) => {
if (arr.length) {
diff --git a/packages/varlet-ui/varlet.config.js b/packages/varlet-ui/varlet.config.js
index 20a46208fad..7c4292de1f3 100644
--- a/packages/varlet-ui/varlet.config.js
+++ b/packages/varlet-ui/varlet.config.js
@@ -19,6 +19,12 @@ module.exports = {
},
},
menu: [
+ {
+ text: {
+ zh_CN: '快速开始',
+ },
+ isTitle: true,
+ },
{
text: {
zh_CN: 'Ripple 水波指令',