You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
---
|
|
|
|
order: 3
|
|
|
|
title:
|
|
|
|
zh-CN: 受控模式
|
|
|
|
en-US: Controlled
|
|
|
|
---
|
|
|
|
|
|
|
|
## zh-CN
|
|
|
|
|
|
|
|
受控模式.
|
|
|
|
|
|
|
|
## en-US
|
|
|
|
|
|
|
|
Controlled mode.
|
|
|
|
|
|
|
|
````jsx
|
|
|
|
import { Mention } from 'antd';
|
|
|
|
const { toEditorState } = Mention;
|
|
|
|
|
|
|
|
class App extends React.Component {
|
|
|
|
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}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
ReactDOM.render(<App />, mountNode);
|
|
|
|
````
|