react native TextInput发送清空内容

2017-03-22  本文已影响4214人  以德扶人

就是设置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:''});

上一篇 下一篇

猜你喜欢

热点阅读