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
|
2019-05-17 12:05:03 +08:00
|
|
|
import { Mentions } from 'antd';
|
2022-05-19 09:46:26 +08:00
|
|
|
import type { OptionProps } from 'antd/es/mentions';
|
2022-05-23 14:37:16 +08:00
|
|
|
import React from 'react';
|
2019-05-17 12:05:03 +08:00
|
|
|
|
|
|
|
const { Option } = Mentions;
|
|
|
|
|
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-05-19 09:46:26 +08:00
|
|
|
const onSelect = (option: OptionProps) => {
|
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"
|
|
|
|
>
|
|
|
|
<Option value="afc163">afc163</Option>
|
|
|
|
<Option value="zombieJ">zombieJ</Option>
|
|
|
|
<Option value="yesmeck">yesmeck</Option>
|
2022-04-03 23:27:45 +08:00
|
|
|
</Mentions>
|
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
|
|
|
```
|