fix(components): [select-v2] the select option style is incorrect (#15501)

* fix(components): [select-v2] the select option style is incorrect

* fix: check option

* chore: update
This commit is contained in:
btea 2024-01-16 16:26:05 +08:00 committed by GitHub
parent 405a4aa393
commit 758d375b7e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -823,6 +823,27 @@ const useSelect = (props: ISelectV2Props, emit) => {
updateOptions()
})
watchEffect(() => {
const { valueKey, options } = props
const duplicateValue = new Map()
for (const item of options) {
const optionValue = getValue(item)
let v = optionValue
if (isObject(v)) {
v = get(optionValue, valueKey)
}
if (duplicateValue.get(v)) {
debugWarn(
'ElSelectV2',
`The option values you provided seem to be duplicated, which may cause some problems, please check.`
)
break
} else {
duplicateValue.set(v, true)
}
}
})
onMounted(() => {
initStates()
})