11import React from 'react' ;
22import '../assets/index.less' ;
33import Cascader from '../src' ;
4+ import type { Option2 } from './utils' ;
45
5- const addressOptions = [
6+ const addressOptions : Option2 [ ] = [
67 // ...new Array(20).fill(null).map((_, i) => ({ label: String(i), value: `99${i}` })),
78 {
89 label : < span > 空孩子</ span > ,
@@ -88,7 +89,7 @@ const addressOptions = [
8889const Demo = ( ) => {
8990 const [ multiple , setMultiple ] = React . useState ( true ) ;
9091
91- const onChange = ( value : any , selectedOptions : any ) => {
92+ const onChange = ( value : string [ ] , selectedOptions : Option2 [ ] ) => {
9293 console . log ( '[DEBUG] onChange - value:' , value ) ;
9394 console . log ( '[DEBUG] onChange - selectedOptions:' , selectedOptions ) ;
9495 } ;
@@ -105,27 +106,19 @@ const Demo = () => {
105106 />
106107 Multiple
107108 </ label >
108- < Cascader
109- style = { { width : 200 } }
110- options = { addressOptions }
111- onChange = { onChange }
112- checkable = { multiple }
113- allowClear
114- // defaultValue={multiple ? [defaultValue] : defaultValue}
115- // defaultValue={[['not', 'yet'], ['exist']]}
116- // defaultValue={[['empty']]}
117- defaultValue = { [ 'fj' , 'fuzhou' ] }
118- showSearch
119- // showSearch={{ limit: 1 }}
120- // open
121- // tagRender={props => {
122- // console.log(props);
123- // return props.label as any;
124- // }}
125- // direction="rtl"
126- // searchValue="福a"
127- // changeOnSelect
128- />
109+ { multiple ? (
110+ < Cascader style = { { width : 200 } } checkable defaultValue = { [ [ 'fj' ] , [ 'fuzhou' ] ] } showSearch />
111+ ) : (
112+ < Cascader
113+ style = { { width : 200 } }
114+ options = { addressOptions }
115+ onChange = { onChange }
116+ checkable = { false }
117+ allowClear
118+ defaultValue = { [ 'fj' , 'fuzhou' ] }
119+ showSearch
120+ />
121+ ) }
129122 </ >
130123 ) ;
131124} ;
0 commit comments