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)}