ts 错误修复
This commit is contained in:
parent
3e7b7db9f8
commit
269555876a
|
@ -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')}>
|
||||||
|
@ -877,15 +876,20 @@ export class Select extends React.Component<SelectProps, SelectState> {
|
||||||
|
|
||||||
{filtedOptions.length ? (
|
{filtedOptions.length ? (
|
||||||
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
|
||||||
itemCount={filtedOptions.length}
|
: filtedOptions.length * itemHeight
|
||||||
itemSize={itemHeight}
|
}
|
||||||
renderItem={renderItem}
|
itemCount={filtedOptions.length}
|
||||||
/>): (
|
itemSize={itemHeight}
|
||||||
filtedOptions.map((item, index) => { return renderItem({index}) })
|
renderItem={renderItem}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
filtedOptions.map((item, index) => {
|
||||||
|
return renderItem({index});
|
||||||
|
})
|
||||||
)
|
)
|
||||||
) : (
|
) : (
|
||||||
<div className={cx('Select-noResult')}>{__(noResultsText)}</div>
|
<div className={cx('Select-noResult')}>{__(noResultsText)}</div>
|
||||||
|
|
Loading…
Reference in New Issue