--- order: 2 title: zh-CN: 受控的 Checkbox en-US: Controlled Checkbox --- ## zh-CN 联动 checkbox。 ## en-US Communicated with other components. ```jsx import React, { useState } from 'react'; import { Checkbox, Button } from 'antd'; export default () => { const [checked, setChecked] = useState(true); const [disabled, setDisabled] = useState(false); const toggleChecked = () => { setChecked(!checked); }; const toggleDisable = () => { setDisabled(!disabled); }; const onChange = e => { console.log('checked = ', e.target.checked); setChecked(e.target.checked); }; const label = `${checked ? 'Checked' : 'Unchecked'}-${disabled ? 'Disabled' : 'Enabled'}`; return ( <>
> ); }; ```