2016-07-04 10:31:27 +08:00
|
|
|
---
|
|
|
|
order: 0
|
2016-09-23 10:14:57 +08:00
|
|
|
title:
|
2016-09-23 09:41:04 +08:00
|
|
|
zh-CN: 基本使用
|
2016-09-23 10:14:57 +08:00
|
|
|
en-US: Basic
|
2016-07-04 10:31:27 +08:00
|
|
|
---
|
|
|
|
|
|
|
|
## zh-CN
|
|
|
|
|
|
|
|
基本使用
|
|
|
|
|
|
|
|
## en-US
|
|
|
|
|
|
|
|
Basic usage.
|
|
|
|
|
2019-05-07 14:57:32 +08:00
|
|
|
```jsx
|
2016-07-04 10:31:27 +08:00
|
|
|
import { Mention } from 'antd';
|
2018-06-27 15:55:04 +08:00
|
|
|
|
2017-05-05 14:53:46 +08:00
|
|
|
const { toString, toContentState } = Mention;
|
2016-07-19 13:39:05 +08:00
|
|
|
|
2017-05-05 14:53:46 +08:00
|
|
|
function onChange(contentState) {
|
|
|
|
console.log(toString(contentState));
|
2016-07-04 10:31:27 +08:00
|
|
|
}
|
|
|
|
|
2016-09-30 11:26:27 +08:00
|
|
|
function onSelect(suggestion) {
|
|
|
|
console.log('onSelect', suggestion);
|
|
|
|
}
|
|
|
|
|
2016-07-04 10:31:27 +08:00
|
|
|
ReactDOM.render(
|
|
|
|
<Mention
|
2017-09-25 22:42:07 +08:00
|
|
|
style={{ width: '100%' }}
|
2016-07-04 10:31:27 +08:00
|
|
|
onChange={onChange}
|
2017-05-05 14:53:46 +08:00
|
|
|
defaultValue={toContentState('@afc163')}
|
2018-12-18 18:32:21 +08:00
|
|
|
defaultSuggestions={['afc163', 'benjycui', 'yiminghe', 'RaoHai', '中文', 'にほんご']}
|
2016-09-30 11:26:27 +08:00
|
|
|
onSelect={onSelect}
|
2018-06-27 15:55:04 +08:00
|
|
|
/>,
|
2019-05-07 14:57:32 +08:00
|
|
|
mountNode,
|
2018-11-28 15:00:03 +08:00
|
|
|
);
|
2019-05-07 14:57:32 +08:00
|
|
|
```
|