【发布时间】:2019-09-12 12:47:02
【问题描述】:
我们将this.state.todos 放入option。 this.state.todos.slice (0.2) 我输入了selected。但是,我无法选择项目并且已删除的项目不会返回到列表中。我正在使用 typeahead react bootstrap 库
在这里演示:https://stackblitz.com/edit/react-agfvwn?file=index.js
class App extends Component {
constructor() {
super();
this.state = {
todos: [{
id:1,
name: 'paul'
},
{
id:2,
name: 'gregor'
},
{
id:3,
name: 'martin'
}],
};
}
handleSelect = (statusFilter) => {
console.log(statusFilter)
this.setState({
todos: statusFilter
})
}
render() {
return (
<div>
<Typeahead
multiple
id={'sasas'}
selected={this.state.todos.slice(0,2)}
labelKey="name"
onChange={this.handleSelect}
options={this.state.todos}
ref={(ref) => this._typeahead = ref}
/>
</div>
);
}
}
【问题讨论】:
标签: javascript reactjs typeahead.js bootstrap-typeahead