2020-10-10 11:30:58 +08:00
|
|
|
---
|
|
|
|
order: 12
|
|
|
|
title:
|
|
|
|
zh-CN: 带字数提示的文本域
|
|
|
|
en-US: Textarea with character counting
|
|
|
|
---
|
|
|
|
|
|
|
|
## zh-CN
|
|
|
|
|
|
|
|
展示字数提示。
|
|
|
|
|
|
|
|
## en-US
|
|
|
|
|
|
|
|
Show character counting.
|
|
|
|
|
2022-05-19 09:46:26 +08:00
|
|
|
```tsx
|
2020-10-10 11:30:58 +08:00
|
|
|
import { Input } from 'antd';
|
2022-05-23 14:37:16 +08:00
|
|
|
import React from 'react';
|
2020-10-10 11:30:58 +08:00
|
|
|
|
|
|
|
const { TextArea } = Input;
|
|
|
|
|
2022-05-19 09:46:26 +08:00
|
|
|
const onChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {
|
2021-03-23 15:03:47 +08:00
|
|
|
console.log('Change:', e.target.value);
|
|
|
|
};
|
|
|
|
|
2022-05-19 09:46:26 +08:00
|
|
|
const App: React.FC = () => (
|
2022-10-06 19:19:16 +08:00
|
|
|
<>
|
|
|
|
<TextArea
|
|
|
|
showCount
|
|
|
|
maxLength={100}
|
|
|
|
style={{ height: 120 }}
|
|
|
|
onChange={onChange}
|
|
|
|
placeholder="can resize"
|
|
|
|
/>
|
|
|
|
<TextArea
|
|
|
|
showCount
|
|
|
|
maxLength={100}
|
|
|
|
style={{ height: 120, resize: 'none' }}
|
|
|
|
onChange={onChange}
|
|
|
|
placeholder="disable resize"
|
|
|
|
/>
|
|
|
|
</>
|
2021-11-27 15:35:42 +08:00
|
|
|
);
|
2022-05-19 09:46:26 +08:00
|
|
|
|
|
|
|
export default App;
|
2020-10-10 11:30:58 +08:00
|
|
|
```
|