@@ -23,18 +23,22 @@ class EasySelect extends React.Component<any, any> {
23
23
24
24
onSearch = ( str : any ) => {
25
25
const { clearValueRequest = false , autoValue } = this . props ;
26
- if ( ! clearValueRequest && ! str ) { // 默认清空展示上次的数据
26
+ if ( ! clearValueRequest && ! str ) {
27
+ // 默认清空展示上次的数据
27
28
this . setState ( { dataSource : this . state . dataSource } )
28
- } else if ( clearValueRequest && ! str ) { // 此时清空展示最初的数据, 进行初始化的请求,参数传入autoValue
29
+ } else if ( clearValueRequest && ! str ) {
30
+ // 此时清空展示最初的数据, 进行初始化的请求,参数传入autoValue
29
31
this . getDataSource ( autoValue ) ;
30
- } else { // 正常搜索函数,特殊处理防抖
32
+ } else {
33
+ // 正常搜索函数,特殊处理防抖
31
34
debounce ( ( ) => this . getDataSource ( str ) , 300 ) ( ) ;
32
35
}
33
36
}
34
37
35
38
lazyDataSource = ( data : any ) => {
36
39
const { scrollPage = 1 } = this . state ;
37
- if ( data . length > ( scrollPage * 100 ) ) {
40
+ const { isLazy = true } = this . props ;
41
+ if ( data . length > ( scrollPage * 100 ) && isLazy ) {
38
42
this . setState ( {
39
43
dataSource : data . slice ( 0 , scrollPage * 100 ) || [ ] ,
40
44
allData : data
@@ -81,8 +85,8 @@ class EasySelect extends React.Component<any, any> {
81
85
onSearch = { servise && ! filterLocal ? this . onSearch : null }
82
86
filterOption = { ! filterLocal ? null : ( input , option ) =>
83
87
// 兼容数字和字符串等模糊查询
84
- option . props . children . toString ( ) . toLowerCase ( ) . indexOf ( input . toLowerCase ( ) ) >= 0 ||
85
- option . props . value . toString ( ) . toLowerCase ( ) . indexOf ( input . toLowerCase ( ) ) >= 0
88
+ option . props ? .children ? .toString ( ) . toLowerCase ( ) . indexOf ( input . toLowerCase ( ) ) >= 0 ||
89
+ option . props ? .value ? .toString ( ) . toLowerCase ( ) . indexOf ( input . toLowerCase ( ) ) >= 0
86
90
}
87
91
onPopupScroll = { this . companyScroll }
88
92
{ ...others }
0 commit comments