ts 错误修复

This commit is contained in:
2betop 2020-08-20 10:09:45 +08:00
parent 3e7b7db9f8
commit 269555876a
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 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 (
<div
{...getItemProps({
@ -835,7 +834,7 @@ export class Select extends React.Component<SelectProps, SelectState> {
)}
</div>
);
}
};
const 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 避免滚动条问题
<VirtualList
height={
filtedOptions.length > 8 ? 280 : filtedOptions.length * itemHeight
filtedOptions.length > 8
? 280
: filtedOptions.length * itemHeight
}
itemCount={filtedOptions.length}
itemSize={itemHeight}
renderItem={renderItem}
/>): (
filtedOptions.map((item, index) => { return renderItem({index}) })
/>
) : (
filtedOptions.map((item, index) => {
return renderItem({index});
})
)
) : (
<div className={cx('Select-noResult')}>{__(noResultsText)}</div>