From 269555876af54f40eb14fb2930639287d3d527e1 Mon Sep 17 00:00:00 2001 From: 2betop <2betop.cn@gmail.com> Date: Thu, 20 Aug 2020 10:09:45 +0800 Subject: [PATCH] =?UTF-8?q?ts=20=E9=94=99=E8=AF=AF=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Select.tsx | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/src/components/Select.tsx b/src/components/Select.tsx index 1fcf760e..9f1dcb77 100644 --- a/src/components/Select.tsx +++ b/src/components/Select.tsx @@ -760,11 +760,10 @@ export class Select extends React.Component { const itemHeight = this.state.itemHeight; // 渲染单个选项 - const renderItem = ({index, style}) => { + const renderItem = ({index, style}: {index: number; style?: object}) => { const item = filtedOptions[index]; const checked = - selectedItem === item || - !!~selectionValues.indexOf(item[valueField]); + selectedItem === item || !!~selectionValues.indexOf(item[valueField]); return (
{ )}
); - } + }; const menu = (
@@ -877,15 +876,20 @@ export class Select extends React.Component { {filtedOptions.length ? ( filtedOptions.length > 100 ? ( // 超过 100 个数据才启用 virtuallist 避免滚动条问题 - 8 ? 280 : filtedOptions.length * itemHeight - } - itemCount={filtedOptions.length} - itemSize={itemHeight} - renderItem={renderItem} - />): ( - filtedOptions.map((item, index) => { return renderItem({index}) }) + 8 + ? 280 + : filtedOptions.length * itemHeight + } + itemCount={filtedOptions.length} + itemSize={itemHeight} + renderItem={renderItem} + /> + ) : ( + filtedOptions.map((item, index) => { + return renderItem({index}); + }) ) ) : (
{__(noResultsText)}