diff --git a/packages/components/select-v2/src/select-dropdown.vue b/packages/components/select-v2/src/select-dropdown.vue index d4204a43db..7d3fb1e7c0 100644 --- a/packages/components/select-v2/src/select-dropdown.vue +++ b/packages/components/select-v2/src/select-dropdown.vue @@ -82,10 +82,11 @@ export default defineComponent({ } const isItemSelected = (modelValue: any[] | any, target: Option) => { + const { valueKey } = select.props if (select.props.multiple) { - return contains(modelValue, target.value) + return contains(modelValue, get(target, valueKey)) } - return isEqual(modelValue, target.value) + return isEqual(modelValue, get(target, valueKey)) } const isItemDisabled = (modelValue: any[] | any, selected: boolean) => { diff --git a/packages/components/select-v2/src/useSelect.ts b/packages/components/select-v2/src/useSelect.ts index 1df3f126d1..365b95e34c 100644 --- a/packages/components/select-v2/src/useSelect.ts +++ b/packages/components/select-v2/src/useSelect.ts @@ -451,7 +451,8 @@ const useSelect = (props: ExtractPropTypes, emit) => { } const deleteTag = (event: MouseEvent, tag: Option) => { - const index = (props.modelValue as Array).indexOf(tag.value) + const { valueKey } = props + const index = (props.modelValue as Array).indexOf(get(tag, valueKey)) if (index > -1 && !selectDisabled.value) { const value = [ @@ -460,7 +461,7 @@ const useSelect = (props: ExtractPropTypes, emit) => { ] states.cachedOptions.splice(index, 1) update(value) - emit('remove-tag', tag.value) + emit('remove-tag', get(tag, valueKey)) states.softFocus = true removeNewOption(tag) return nextTick(focusAndUpdatePopup)