美文网首页
react native TextInput发送清空内容

react native TextInput发送清空内容

作者: 以德扶人 | 来源:发表于2017-03-22 17:06 被阅读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:''});

相关文章

网友评论

      本文标题:react native TextInput发送清空内容

      本文链接:https://www.haomeiwen.com/subject/bynonttx.html