--- order: 2 title: 和外部组件通信 --- 联动 checkbox。 ````jsx import { Checkbox, Button } from 'antd'; const App = React.createClass({ getInitialState() { return { checked: true, disabled: false }; }, render() { const label = `${this.state.checked ? '选中' : '取消'}-${this.state.disabled ? '不可用' : '可用'}`; return (

{label}

); }, toggleChecked() { this.setState({ checked: !this.state.checked }); }, toggleDisable() { this.setState({ disabled: !this.state.disabled }); }, onChange(e) { console.log('checked = ', e.target.checked); this.setState({ checked: e.target.checked, }); } }); ReactDOM.render(, mountNode); ````