0.0.3 • Published 7 years ago

nuke-text-input v0.0.3

Weekly downloads
16
License
-
Repository
gitlab
Last release
7 years ago

TextInput

  • category: Components
  • chinese: 输入框
  • type: 基本

何时使用

TextInput 是唤起用户输入的基础组件。 当定义 multiline 输入多行文字时其功能相当于 textarea。

API

属性说明类型默认值
multiline【与multiple 重复,即将废弃】定义该属性文本框可以输入多行文字booleanfalse
multiple定义该属性文本框可以输入多行文字booleanfalse
accessibilityLabel为元素添加标识string
autoComplete添加开启自动完成功能booleanfalse//todo
autoFocus添加开启获取焦点booleanfalse
editable文本框是否可编辑booleantrue
keyboardType【 与type 重复,即将废弃】设置弹出哪种软键盘 可用的值有default ascii-capable numbers-and-punctuation url number-pad phone-pad name-phone-pad email-address decimal-pad twitter web-search numericstringdefault
type设置弹出哪种软键盘 可用的值有text number url password tel date time emailstringtext
maxLength设置最大可输入值number
maxNumberOfLines当文本框为mutiline时设置最多的行数number
numberOfLines同上设置行数number
placeholder设置文本框提示string
password【与type 重复,即将废弃】文本框内容密码显示
secureTextEntry【与type 重复,即将废弃】同上文本框内容密码显示
value文本框的文字内容string
style自定义样式Object

同时 TextInput 响应下面几个事件:

  • onBlur: 文本框失焦时调用此函数。onBlur={() => console.log('失焦啦')}
  • onFocus: 文本框获得焦点时调用此函数
  • onChange: 文本框内容变化时调用此函数
  • onInput: 文本框输入内容时调用此函数

使用示例:

<TextInput
        placeholder="Enter text to see events"
        autoFocus multiline
        onFocus={() => console.log('onFocus')}
        onBlur={() => console.log('onBlur')}
        onInput={() => console.log('onInput')}
        style={{
                width: '1000rem',
                height: '1000rem',
                borderWidth:'1rem',
                borderStyle:'solid',
                borderColor:'#cccccc'
        }}
/>