@@ -9,14 +9,14 @@ Input 文本输入
99
1010import React from ' react' ;
1111import { View , Input } from ' @uiw/react-native' ;
12+ import {View } from ' react-native' ;
1213
1314export default class BasicInputExample extends React .Component {
1415 render () {
1516 return < View>
1617 < Input onChange= {(value ) => {this .setState ({value})}} value= {this .state .value } / >
1718 < Input extra= " 小数" / >
1819 < Input error / >
19- < Input type= " phone" / >
2020 < / View>
2121 }
2222}
@@ -26,13 +26,65 @@ export default class BasicInputExample extends React.Component {
2626
2727## Props
2828
29- | 参数 | 说明 | 类型 | 默认值 |
30- | ------| ------| -----| ------|
31- | ` clear ` | 是否显示清除按钮 | boolean | false |
32- | ` extra ` | 额外的文字 | ReactNode \| string | - |
33- | ` error ` | 是否显示错误 | boolean | false |
34- | ` onExtraClick ` | ` extra ` 点击事件触发的回调函数 | (e: Object): void | - |
35- | ` onErrorClick ` | 点击报错 ` icon ` 触发的回调函数 | (e: Object): void | - |
29+ ``` tsx
30+ import { StyleProp ,TextStyle ,TextInputProps , NativeSyntheticEvent , TextInputFocusEventData , TextInputChangeEventData , KeyboardTypeOptions ,ViewStyle } from ' react-native'
31+
32+ export interface InputProps extends TextInputProps {
33+ /** 输入框默认值 */
34+ value? : string ;
35+ /** 限制输入条件 */
36+ rule? : RegExp | (value : string )=> boolean ;
37+ /** 输入不合法时触发方法 */
38+ wrongfulHandle? : Function ;
39+ /** 限制文本框中最多的字符数。使用这个属性而不用 JS 逻辑去实现,可以避免闪烁的现象。 */
40+ maxLength? : number ;
41+ /** 如果没有任何文字输入,会显示此字符串。 */
42+ placeholder: string ;
43+ /** 输入框样式 */
44+ style? : StyleProp <TextStyle >;
45+ /** 容器样式 */
46+ containerStyle? : StyleProp <ViewStyle >;
47+ /** 显示错误 */
48+ error? : boolean ;
49+ /** 自定义错误提示 */
50+ renderError? : React .ReactNode ;
51+ /** 边框 */
52+ border? : ' bottom' | ' top' | ' left' | ' right' | null | ' always' ;
53+ /** 边框颜色 */
54+ borderColor? : string ;
55+ /** 唤起键盘类型 详情 https://lefkowitz.me/visual-guide-to-react-native-textinput-keyboardtype-options/ */
56+ keyboardType? : KeyboardTypeOptions ;
57+ /** 如果为 true,文本框是不可编辑的。默认值为 false */
58+ disabled? : boolean ;
59+ /** 如果为 true,在componentDidMount后会获得焦点。默认值为 false。 */
60+ autoFocus? : boolean ;
61+ /** 设置输入框高亮时的颜色(还包括光标)。 */
62+ selectionColor? : string ;
63+ /** 如果为 true,则隐藏光标。默认值为 false。 */
64+ caretHidden? : boolean ;
65+ /** 是否显示清除按钮 */
66+ clear? : boolean ;
67+ /** 清除按钮样式 */
68+ clearStyle? : StyleProp <TextStyle >;
69+ /** 自定义清除元素 */
70+ renderClear? : React .ReactNode ;
71+ /** 如果为 true,每次开始输入的时候都会清除文本框的内容。 */
72+ clearText? : boolean ;
73+ /** 输入框前缀的额外的信息 */
74+ extraStart? : string | React .ReactNode
75+ /** 输入框末尾额外的信息 */
76+ extraEnd? : string | React .ReactNode
77+ /** 当文本框内容变化时调用此回调函数。改变后的文字内容会作为参数传递 */
78+ onChangeText? : ((text : string ) => void );
79+ /** 当文本框失去焦点的时候调用此回调函数。 */
80+ onBlur? : ((e : NativeSyntheticEvent <TextInputFocusEventData >) => void );
81+ /** 当文本框内容变化时调用此回调函数。回调参数为{ nativeEvent: { eventCount, target, text} }。 */
82+ onChange? : ((e : NativeSyntheticEvent <TextInputChangeEventData >) => void );
83+ /** 输入框 ref */
84+ inputRef? : React .RefObject <TextInput >
85+ }
86+
87+ ```
3688
3789
38- > 更多 react-native InputItem 属性请参考 react-native TextInput (http ://facebook.github.io/ react-native/docs/textinput.html )
90+ > 更多 react-native Input 属性请参考 react-native TextInput (https ://www. react-native.cn /docs/textinput)
0 commit comments