React-Native Text,TextInput控件常见问题及解决方案

1.在使用React-Navtive标签时,有时会出现一行内容显示不开的情形,此时需要Text的高度随着文字内容的增加,而增加。


    啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦
        啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦
        啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦
        啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦
        啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦
        啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦
        啦啦啦啦啦
        啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦
        啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦
        啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦

此时可以设置view的样式设置最小高度,及间距,即可

flexRow:{
    flexDirection: 'row',
    minHeight: 40,
    padding: 10,
    borderBottomWidth:1,
    borderTopWidth:1,
},

text:{
    fontSize:11,
    color:'#000',
},

效果图React-Native Text,TextInput控件常见问题及解决方案_第1张图片

2.在使用TextFeild时如果设置value值为state里的一个属性,并且在onChangeState方法里,改变这个state那么会造成,每当输入内容时,造成TextField刷新,导致输入不正常,因此应该避免此种情况。

 this.setState({inputValue:text})}>
 

3.在设置样式时,若想,一个父视图里的某个子视图充满剩余的空间,那么需要将其style 中flex设置为1,并将其余子视图大小固定即可。


    里程
     this.setState({inputValue:text})}/> 
    公里

你可能感兴趣的:(React-Native Text,TextInput控件常见问题及解决方案)