react native TextInput发送清空内容

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

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 40、React 什么是React?React 是一个用于构建用户界面的框架(采用的是MVC模式):集中处理VIE...
    萌妹撒阅读 1,059评论 0 1
  • 作为一个合格的开发者,不要只满足于编写了可以运行的代码。而要了解代码背后的工作原理;不要只满足于自己的程序...
    六个周阅读 8,529评论 1 33
  • 个人笔记, 转载请注明转载自 szhshp的第三边境研究所 Refs and the DOM In the t...
    szhielelp阅读 1,508评论 0 1
  • 前言 组件中的state具体是什么?怎么更改state的数据? setState函数分别接收对象以及函数有什么区别...
    itclanCoder阅读 925评论 0 0
  • React 教程 React 是一个用于构建用户界面的 JAVASCRIPT 库。React主要用于构建UI,很多...
    StevenHu_Sir阅读 4,847评论 0 1