2016-10-20 13:51:44 +08:00
|
|
|
---
|
|
|
|
order: 3
|
|
|
|
title:
|
|
|
|
zh-CN: 受控模式
|
|
|
|
en-US: Controlled
|
|
|
|
---
|
|
|
|
|
|
|
|
## zh-CN
|
|
|
|
|
|
|
|
受控模式.
|
|
|
|
|
|
|
|
## en-US
|
|
|
|
|
|
|
|
Controlled mode.
|
|
|
|
|
2017-01-19 15:19:03 +08:00
|
|
|
````__react
|
2016-10-20 13:51:44 +08:00
|
|
|
import { Mention } from 'antd';
|
|
|
|
const { toEditorState } = Mention;
|
|
|
|
|
|
|
|
const App = React.createClass({
|
|
|
|
getInitialState() {
|
|
|
|
return {
|
|
|
|
value: toEditorState('@afc163'),
|
|
|
|
};
|
|
|
|
},
|
|
|
|
handleChange(editorState) {
|
|
|
|
this.setState({
|
|
|
|
value: editorState,
|
|
|
|
});
|
|
|
|
},
|
|
|
|
render() {
|
|
|
|
return (<Mention
|
|
|
|
suggestions={['afc163', 'benjycui', 'yiminghe', 'RaoHai', '中文', 'にほんご']}
|
|
|
|
value={this.state.value}
|
|
|
|
onChange={this.handleChange}
|
|
|
|
/>);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
ReactDOM.render(<App />, mountNode);
|
|
|
|
````
|