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.
|
|
|
|
|
2017-01-19 15:19:03 +08:00
|
|
|
````__react
|
2016-07-04 10:31:27 +08:00
|
|
|
import { Mention } from 'antd';
|
2016-07-19 13:39:05 +08:00
|
|
|
const { toString, toEditorState } = Mention;
|
|
|
|
|
2016-07-19 12:31:03 +08:00
|
|
|
function onChange(editorState) {
|
|
|
|
console.log(toString(editorState));
|
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
|
2016-10-31 15:39:03 +08:00
|
|
|
style={{ width: '100%', height: 100 }}
|
2016-07-04 10:31:27 +08:00
|
|
|
onChange={onChange}
|
2016-07-19 13:39:05 +08:00
|
|
|
defaultValue={toEditorState('@afc163')}
|
2016-07-20 18:56:44 +08:00
|
|
|
suggestions={['afc163', 'benjycui', 'yiminghe', 'RaoHai', '中文', 'にほんご']}
|
2016-09-30 11:26:27 +08:00
|
|
|
onSelect={onSelect}
|
2016-07-21 15:40:13 +08:00
|
|
|
/>
|
|
|
|
, mountNode);
|
2016-07-04 10:31:27 +08:00
|
|
|
````
|