我正在使用本机UI组件来选择值并 设置它。但是所选值不会停留在屏幕上。看不到 选择的值。为什么这样?
`
onChangeHandler = (e) => {
this.setState({
selectValue: e
});
}
render() {
sports = [
{ value:'Basketball' },
{ value:'Football' },
{ value:'Tennis' },
{ value:'Volleyball' }
];
<Dropdown
value={this.state.selectValue}
data = {sports}
style={styles.Dropdown1}
onChangeText = {(event) => this.onChangeHandler(event)}
><Dropdown>
}
答案 0 :(得分:0)
尝试console.log()
您正在通过的事件,并查看该事件中引发了什么
我会尝试以下操作:
onChangeHandler = (evt) => {
this.setState({
selectValue: evt.target.value
});
}
render() {
sports = [
{ value:'Basketball' },
{ value:'Football' },
{ value:'Tennis' },
{ value:'Volleyball' }
];
<Dropdown
value={this.state.selectValue}
data = {sports}
style={styles.Dropdown1}
onChangeText = {this.onChangeHandler}
><Dropdown>
}