mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-23 23:18:36 +08:00
40 lines
614 B
Markdown
40 lines
614 B
Markdown
---
|
|
order: 0
|
|
title:
|
|
zh-CN: 基本使用
|
|
en-US: Basic
|
|
---
|
|
|
|
## zh-CN
|
|
|
|
基本使用
|
|
|
|
## en-US
|
|
|
|
Basic usage.
|
|
|
|
````jsx
|
|
import { Mention } from 'antd';
|
|
|
|
const { toString, toContentState } = Mention;
|
|
|
|
function onChange(contentState) {
|
|
console.log(toString(contentState));
|
|
}
|
|
|
|
function onSelect(suggestion) {
|
|
console.log('onSelect', suggestion);
|
|
}
|
|
|
|
ReactDOM.render(
|
|
<Mention
|
|
style={{ width: '100%' }}
|
|
onChange={onChange}
|
|
defaultValue={toContentState('@afc163')}
|
|
suggestions={['afc163', 'benjycui', 'yiminghe', 'RaoHai', '中文', 'にほんご']}
|
|
onSelect={onSelect}
|
|
/>,
|
|
mountNode
|
|
);
|
|
````
|