就是设置value的值
value = {this.state.inputText}
constructor(props) {
super(props);
this.state = {
inputText:'',
};
}
<TextInput
ref = 'textInput'
style = {{marginLeft:10,marginRight:10,height:40,fontSize:13}}
returnKeyType = "default"
placeholder= "说点什么吧"
underlineColorAndroid='transparent'
onFocus={this.scrollViewTo.bind(this)}
onEndEditing={()=>{this.refs.scroll.scrollTo({y:0,x:0,animated:true})}}
onChangeText={(text) => {this.setState({inputText:text})}}
value = {this.state.inputText}
clearButtonMode="while-editing"
/>
在要清空的方法里面放入清空即可
this.setState({inputText:''});
网友评论