2.0.0 • Published 6 years ago

react-native-custom-input v2.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

react-native-custom-textInput

react-native-custom-input,一个自定义的输入组件

The final rendering

The final rendering

Installation:


 npm install --save react-native-custom-input

Example usage:


1.basic

import Input from react-native-custom-input;

   ...
  render() {
    return (
        <Input />
    );
  }

Props:

PropsExplaintyperequiredefault
label输入框的名称stringno文本输入框
value输入框的值anyyes''
labelTextStyle输入框的名称的样式stringno{ width: 100,flexDirection: 'row',justifyContent: 'flex-end', alignItems: 'center',marginLeft: 15,}
required是否显示必输标志booleannofalse
mode输入框的模式,具体有简单输入框还是输入域stringno简单文本输入框,值为('Input','TextArea')两者之一
textInputStyle输入框的样式objectno{fontSize: 14, color: '#332f2b'}
isUpdate是否可编辑,true为可编辑booleannotrue
suffix输入框后面的后缀,值得注意的是length大于3的时候将不会显示stringno''
placeholderTextColor占位符文字的颜色stringno'#ccc8c4'
autoCapitalize首字母是否自动大写stringno'none',只能是'characters', 'words', 'sentences', 'none'之一

注意: 由于输入框组件是在react-native官方组件的基础上进行封装,所以支持TextInput所有属性,在这里就不一一罗列

Examples from props:

...
  _onChange = (label, value) => {
    this.setState({ [label]: value });
  };

  render() {
    return (
      <View style={styles.container}>
        <Text>
          {this.state.result}
        </Text>
        <Input onChange={(value) => this._onChange('input1', value)} value={this.state.input1 || ''} />
        <Input label={'姓名'} onChange={(value) => this._onChange('input2', value)} value={this.state.input2 || ''} />
        <Input onChange={(value) => this._onChange('input3', value)} mode={'TextArea'} label={'详细地址'} value={this.state.input3 || ''} />
      </View>
    );
  }
...

LICENSE:


MIT