Skip to content

Commit

Permalink
fix(TextArea): 增加自定义高度
Browse files Browse the repository at this point in the history
  • Loading branch information
ChenlingasMx committed Mar 10, 2023
1 parent fad9f30 commit dbe79d9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion example/examples/src/routes/TextArea/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ export default class TextAreaView extends Component<TextAreaProps> {
</Card>
<Card title="自定义输入框样式" style={styles.card}>
<TextArea
height={150}
style={{
height: 150,
borderColor: 'blue',
borderWidth: 2,
}}
Expand Down
11 changes: 6 additions & 5 deletions packages/core/src/TextArea/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ function Demo() {
onChange={(value) => {
setValue(value);
}}
height={150}
style={{
height: 150,
borderColor: 'green',
borderWidth: 2,
}}
Expand Down Expand Up @@ -200,12 +200,13 @@ export default Demo
| 参数 | 说明 | 类型 | 默认值 |
|------|------|-----|------|
| `textAlignVertical` | 文本位置 | "top" \| "center" \| "auto" \| "bottom" | `top` |
| `placeholder` | 默认提示语 | String | |
| `placeholder` | 默认提示语 | String | - |
| `placeholderTextColor` | 提示语颜色 | `string` | `#989FB2` |
| `maxLength` | 最大字符数 | `number` | `100` |
| `numberOfLines` | 输入框的行数(Android) | `number` | `30` |
| `editable` | 是否禁用 | `boolean` | `true` |
| `onChange` | 文本域内容变化时触发 | `(val: string) => void` | |
| `value` | 文本框中的文字内容 | `string` | |
| `onChange` | 文本域内容变化时触发 | `(val: string) => void` | - |
| `value` | 文本框中的文字内容 | `string` | - |
| `showWords` | 是否展示字数 | `boolean` | `false` |
| `fontStyle` | 输入框文字样式 | ` StyleProp<TextStyle>` | |
| `fontStyle` | 输入框文字样式 | ` StyleProp<TextStyle>` | - |
| `height` | 输入框高度 | `number` | 0 |
4 changes: 3 additions & 1 deletion packages/core/src/TextArea/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export interface TextAreaProps extends ViewProps {
fontStyle?: StyleProp<TextStyle>;
/** 自适应内容高度 */
autoSize?: boolean;
height?: number;
}

function TextArea(props: TextAreaProps) {
Expand All @@ -58,11 +59,12 @@ function TextArea(props: TextAreaProps) {
autoSize = false,
style,
fontStyle,
height: defaultHeight = 0,
...other
} = props;

const [defaultText, setDefaultText] = useState<string>('');
const [height = 0, setHeight] = useState<number>(0);
const [height = 0, setHeight] = useState<number>(defaultHeight);

const onChangeValue = (event: NativeSyntheticEvent<TextInputChangeEventData>) => {
if (autoSize) {
Expand Down

0 comments on commit dbe79d9

Please sign in to comment.