ts 错误修复

This commit is contained in:
2betop 2020-08-20 10:09:45 +08:00
parent ad00c8f34f
commit 794ac5f6bc
1 changed files with 17 additions and 13 deletions

View File

@ -760,11 +760,10 @@ export class Select extends React.Component<SelectProps, SelectState> {
const itemHeight = this.state.itemHeight; const itemHeight = this.state.itemHeight;
// 渲染单个选项 // 渲染单个选项
const renderItem = ({index, style}) => { const renderItem = ({index, style}: {index: number; style?: object}) => {
const item = filtedOptions[index]; const item = filtedOptions[index];
const checked = const checked =
selectedItem === item || selectedItem === item || !!~selectionValues.indexOf(item[valueField]);
!!~selectionValues.indexOf(item[valueField]);
return ( return (
<div <div
{...getItemProps({ {...getItemProps({
@ -835,7 +834,7 @@ export class Select extends React.Component<SelectProps, SelectState> {
)} )}
</div> </div>
); );
} };
const menu = ( const menu = (
<div ref={this.menu} className={cx('Select-menu')}> <div ref={this.menu} className={cx('Select-menu')}>
@ -879,13 +878,18 @@ export class Select extends React.Component<SelectProps, SelectState> {
filtedOptions.length > 100 ? ( // 超过 100 个数据才启用 virtuallist 避免滚动条问题 filtedOptions.length > 100 ? ( // 超过 100 个数据才启用 virtuallist 避免滚动条问题
<VirtualList <VirtualList
height={ height={
filtedOptions.length > 8 ? 280 : filtedOptions.length * itemHeight filtedOptions.length > 8
? 280
: filtedOptions.length * itemHeight
} }
itemCount={filtedOptions.length} itemCount={filtedOptions.length}
itemSize={itemHeight} itemSize={itemHeight}
renderItem={renderItem} renderItem={renderItem}
/>): ( />
filtedOptions.map((item, index) => { return renderItem({index}) }) ) : (
filtedOptions.map((item, index) => {
return renderItem({index});
})
) )
) : ( ) : (
<div className={cx('Select-noResult')}>{__(noResultsText)}</div> <div className={cx('Select-noResult')}>{__(noResultsText)}</div>