ant-design/components/input/demo/show-count.md

37 lines
591 B
Markdown
Raw Normal View History

---
order: 12
title:
zh-CN: 带字数提示
en-US: With character counting
---
## zh-CN
展示字数提示。
## en-US
Show character counting.
```tsx
import { Input } from 'antd';
2022-05-23 14:37:16 +08:00
import React from 'react';
const { TextArea } = Input;
const onChange = (e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {
console.log('Change:', e.target.value);
};
const App: React.FC = () => (
<>
<Input showCount maxLength={20} onChange={onChange} />
<br />
<br />
<TextArea showCount maxLength={100} onChange={onChange} />
</>
);
export default App;
```