ant-design/components/mentions/demo/basic.md

54 lines
813 B
Markdown
Raw Normal View History

---
order: 0
title:
zh-CN: 基本使用
en-US: Basic
---
## zh-CN
基本使用。
## en-US
Basic usage.
```tsx
2022-05-23 14:37:16 +08:00
import React from 'react';
import { Mentions } from 'antd';
import type { MentionsOptionProps } from 'antd/es/mentions';
const onChange = (value: string) => {
console.log('Change:', value);
};
const onSelect = (option: MentionsOptionProps) => {
console.log('select', option);
};
const App: React.FC = () => (
<Mentions
style={{ width: '100%' }}
onChange={onChange}
onSelect={onSelect}
defaultValue="@afc163"
options={[
{
value: 'afc163',
label: 'afc163',
},
{
value: 'zombieJ',
label: 'zombieJ',
},
{
value: 'yesmeck',
label: 'yesmeck',
},
]}
/>
);
export default App;
```