设为首页 加入收藏

TOP

React-Native 之 TextInput使用(二)
2017-10-12 18:00:53 】 浏览:10064
Tags:React-Native TextInput 使用
TextInput style={styles.textInputStyle} placeholder="characters" autoCapitalize="characters" ></TextInput> </View> ); } });

效果:
autoCapitalize.gif

  • autoCorrect:如果为false,会关闭拼写自动修正。默认值是true。

  •     var textInputTest = React.createClass({
            render(){
                return(
                    <View style={styles.container}>
                        {/* 文本输入框 */}
                    <TextInput
                        style={styles.textInputStyle}
                        placeholder="没有自动改正拼写"
                        autoCorrect={false}
                    ></TextInput>
                    {/* 文本输入框 */}
                    <TextInput
                        style={styles.textInputStyle}
                        placeholder="自动改正拼写"
                        autoCorrect={true}
                    ></TextInput>
                    </View>
                );
            }
        });
    

    效果:

    autoCorrect.gif

    • autoFocus:如果为true,在componentDidMount后会获得焦点。默认值为false。
        var textInputTest = React.createClass({
            render(){
                return(
                    <View style={styles.container}>
                        {/* 文本输入框 */}
                        <TextInput
                            style={styles.textInputStyle}
                            autoFocus={true}
                        ></TextInput>
                    </View>
                );
            }
        });
    

    效果:

    autoFocus.gif

    • clearButtonMode:清除按钮出现的时机
      • never:不出现
      • while-editing:编辑的时候出现
      • unless-editing:没有编辑时出现
      • always:总是出现
          var textInputTest = React.createClass({
              render(){
                  return(
                      <View style={styles.container}>
                          {/* 文本输入框 */}
                  <TextInput
                      style={styles.textInputStyle}
                      placeholder="never"
                      clearButtonMode="never"
                  ></TextInput>
                  {/* 文本输入框 */}
                  <TextInput
                      style={styles.textInputStyle}
                      placeholder="while-editing"
                      clearButtonMode="while-editing"
                  ></TextInput>
                  {/* 文本输入框 */}
                  <TextInput
                      style={styles.textInputStyle}
                      placeholder="unless-editing"
                      clearButtonMode="unless-editing"
                  ></TextInput>
                  {/* 文本输入框 */}
                  <TextInput
                      style={styles.textInputStyle}
                      placeholder="always"
                      clearButtonMode="always"
                  ></TextInput>
                      </View>
                  );
              }
          });
      
      效果:

    clearButtonMode.gif

    • clearTextOnFocus:如果为true,每次开始输入的时候都会清除文本框的内容

          var textInputTest = React.createClass({
              render(){
                  return(
                      <View style={styles.container}>
                          {/* 文本输入框 */}
                          <TextInput
                              style={styles.textInputStyle}
                              clearTextOnFocus={true}
                          ></TextInput>
                      </View>
                  );
              }
          });
      

      效果:

    clearTextOnFocus.gif

    • editable:如果值为假,文本是不可编辑,默认值为真
        var textInputTest = React.createClass({
            render(){
                return(
                    <View style={styles.container}>
                        {/* 文本输入框 */}
                        <TextInput
                            style={styles.textInputStyle}
                            editable={false}
                        ></TextInput>
                    </View>
                );
            }
        });
    

    效果:

    editable.gif

    • enablesReturnKeyAutomatically:如果为true,键盘会在文本框内没有文字的时候禁用确认按钮。默认值为false。
        var textInputTest = React.createClass({
            render(){
                return(
                    <View style={styles.container}>
                        {/* 文本输入框 */}
                    <TextInput
                        style={styles.textInputStyle}
                        enablesReturnKeyAutomatically={true}
                    ></TextInput>
                    {/* 文本输入框 */}
                    <TextInput
                        style={styles.textInputStyle}
                        enablesReturnKeyAutomatically={false}
                    ></TextInput>
                    </View>
                );
            }
        });
    

    效果:

    enablesReturnKeyAutomatically.gif

    • returnKeyType:决定返回键的样式
      • default
      • go
      • google
      • join
      • next
      • route
      • search
      • send
      • yahoo
      • done
      • emergency-call


          var textInputTest = React.createClass({
              render(){
                  return(
                      <View style={styles.container}>
                          {/* 文本输入框 */}
                      <TextInput
                          style={styles.textInputStyle}
                          returnKeyType="go"
                      ></TextInput>
                      {/* 文本输入框 */}
                      <TextInput
                          style={styles.textInputStyle}
                          returnKeyType="
    首页 上一页 1 2 3 下一页 尾页 2/3/3
    】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
    上一篇指纹识别 下一篇iOS点击推送消息跳到应用指定页面

    最新文章

    热门文章

    Hot 文章

    Python

    C 语言

    C++基础

    大数据基础

    linux编程基础

    C/C++面试题目