From 7f34fe81a742483e3267cf3597d1f7803419369d Mon Sep 17 00:00:00 2001 From: aring <1873748463@qq.com> Date: Fri, 24 May 2024 10:08:06 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=99=9A=E6=8B=9F=E6=BB=9A=E5=8A=A8?= =?UTF-8?q?=E4=B8=8B=EF=BC=8Cvalue=E5=80=BC=E4=B8=8D=E5=AD=98=E5=9C=A8?= =?UTF-8?q?=E6=97=B6=E9=80=89=E9=A1=B9=E4=B8=8D=E6=B8=B2=E6=9F=93=E9=97=AE?= =?UTF-8?q?=E9=A2=98=20(#807)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: 虚拟滚动下,value值不存在时选项不渲染问题 * refactor: all key * refactor: all key to string --------- Co-authored-by: letgo --- components/select/optionList.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/components/select/optionList.tsx b/components/select/optionList.tsx index 81a8f687..067950da 100644 --- a/components/select/optionList.tsx +++ b/components/select/optionList.tsx @@ -164,6 +164,8 @@ export default defineComponent({ const renderDefault = ({ source }: { source: SelectOption }) => source.__isGroup ? renderGroupOption(source) : renderOption(source); + const inValidValueKey = '_ALL_KEY_' + return () => enableVirtualScroll.value ? ( @@ -172,7 +174,12 @@ export default defineComponent({ emit('scroll', event); }} dataSources={props.options} - dataKey={'value'} + dataKey={(data) => + // 兼容全部选项,value为空值的选项 + data.value === null || data.value === undefined + ? inValidValueKey + String(data.value) + : data.value + } estimateSize={32} keeps={14} style={props.containerStyle}