checkboxList component for React native
npm install react-native-checkboxlist-0.51``sh`
npm install react-native-checkboxlist --save
这里是组件使用的概述。
`jsx`
import CheckboxList from 'react-native-checkboxlist'`$3
jsx`
'Lorem ipsum dolor sit',
'Lorem ipsum',
'Lorem ipsum dolor sit amet, consetetur sadipscing elitr',
'Lorem ipsum dolor sit amet, consetetur'
]}
selectedOptions={['Lorem ipsum']}
maxSelectedOptions={2}
onSelection={(option)=>alert(option + ' was selected!')}
/>`$3
分别设置值和显示文字jsx`
{label:'Lorem ipsum dolor sit',value:'A'},
{label:'Lorem ipsum',value:'B'},
{label:'Lorem ipsum dolor sit amet, consetetur sadipscing elitr',value:'C'},
{label:'Lorem ipsum dolor sit amet, consetetur',value:'D'}
]}
selectedOptions={['A','C']}
onSelection={(option)=>alert(option + ' was selected!')}
/>属性
* style - {} custom style of the listoptionStyle - {}
* custom style of the option elementoptions - []
* required array of optionsselectedOptions - []
* optional array of initially selected optionsmaxSelectedOptions - int
* optional maximum number of selectable optionsonSelection - function(option){}
* option selection callbackrenderIndicator - function(option)
* should return a selected/deselected indicator node, default: check mark imagerenderSeparator - function(option)
* should return a separator node that is displayed between the options, default: gray linerenderText - function(option)
* should return a text node, default: text noderenderRow - function(option)
* should return a option viewdisabled - bool` if set to true component is disabled and can't be interacted with
*
示例2