onSelectAll 选项在 react-bootstrap-multiselect 中不起作用

onSelectAll option is not working in react-bootstrap-multiselect

我想添加 select all 属性 到 multiselect,我添加了 onSelectAll 属性但是我看不到 select all 选项。

见下面的代码。

<Multiselect 
     data={this.props.list} 
     multiple 
     ref="industry" 
     onSelectAll 
     onChange={this.handleDropdown.bind(this, 'industry')} 
     buttonText={function(options, select) { 
                     return 'Industry ('+ options.length+')'; }} 
/>

我错过了什么吗?

您需要添加 includeSelectAllOption。这在原始插件here

中有描述
<Multiselect 
 data={this.props.list} 
 includeSelectAllOption
 multiple 
 ref="industry" 
 onSelectAll={this.selectAll} 
 onChange={this.handleDropdown.bind(this, 'industry')} 
 buttonText={function(options, select) { 
                 return 'Industry ('+ options.length+')'; }} 

/>

你的onSelectAll应该是一个函数。当用户从下拉菜单中选择 Select all

时将调用此函数