From 84f5d6f13a99b19310edb2e0282e14869f9cd8a5 Mon Sep 17 00:00:00 2001 From: sea <45450994+warmthsea@users.noreply.github.com> Date: Tue, 12 Nov 2024 15:57:27 +0800 Subject: [PATCH] fix(components): [select] getValueIndex empty error (#18867) * fix(components): [select] getValueIndex judgment error * feat: update --- packages/components/select/src/useSelect.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/components/select/src/useSelect.ts b/packages/components/select/src/useSelect.ts index dad32e613f..010981c38a 100644 --- a/packages/components/select/src/useSelect.ts +++ b/packages/components/select/src/useSelect.ts @@ -589,7 +589,8 @@ export const useSelect = (props: ISelectProps, emit) => { } const getValueIndex = (arr: any[] = [], option) => { - if (!isObject(option?.value)) return arr.indexOf(option.value) + if (isUndefined(option)) return -1 + if (!isObject(option.value)) return arr.indexOf(option.value) return arr.findIndex((item) => { return isEqual(get(item, props.valueKey), getValueKey(option))