fix: 🐛 修复 drop-menu-item 有选项值为空字符串时导致新值错误并触发组件内部警告的问题

This commit is contained in:
drylint 2025-03-16 21:49:03 +08:00 committed by GitHub
parent 6f12aa4b04
commit f63de5bd1d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -128,9 +128,10 @@ function choose(index: number) {
if (props.disabled) return if (props.disabled) return
const { valueKey } = props const { valueKey } = props
const item = props.options[index] const item = props.options[index]
emit('update:modelValue', item[valueKey] !== '' && item[valueKey] !== undefined ? item[valueKey] : item) const newValue = item[valueKey] !== undefined ? item[valueKey] : item
emit('update:modelValue', newValue)
emit('change', { emit('change', {
value: item[valueKey] !== '' && item[valueKey] !== undefined ? item[valueKey] : item, value: newValue,
selectedItem: item selectedItem: item
}) })
close() close()