ant-design/components/mention/demo/controllder-simple.md

42 lines
650 B
Markdown
Raw Normal View History

---
order: 3
title:
zh-CN: 受控模式
en-US: Controlled
---
## zh-CN
受控模式.
## en-US
Controlled mode.
2017-02-13 10:55:53 +08:00
````jsx
import { Mention } from 'antd';
const { toEditorState } = Mention;
class App extends React.Component {
2017-02-20 21:47:57 +08:00
state = {
value: toEditorState('@afc163'),
}
handleChange = (editorState) => {
this.setState({
value: editorState,
});
}
render() {
return (
<Mention
suggestions={['afc163', 'benjycui', 'yiminghe', 'RaoHai', '中文', 'にほんご']}
value={this.state.value}
onChange={this.handleChange}
/>
);
2017-02-20 22:09:13 +08:00
}
});
ReactDOM.render(<App />, mountNode);
````