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