2016-03-31 09:40:55 +08:00
|
|
|
---
|
|
|
|
order: 1
|
2016-07-26 09:17:46 +08:00
|
|
|
title:
|
|
|
|
zh-CN: 不可用
|
|
|
|
en-US: Disabled
|
2016-03-31 09:40:55 +08:00
|
|
|
---
|
2015-07-13 16:51:56 +08:00
|
|
|
|
2016-07-26 09:17:46 +08:00
|
|
|
## zh-CN
|
|
|
|
|
2015-07-20 14:32:21 +08:00
|
|
|
Switch 失效状态。
|
2015-07-13 16:51:56 +08:00
|
|
|
|
2016-07-26 09:17:46 +08:00
|
|
|
## en-US
|
|
|
|
|
|
|
|
Disabled state of `Switch`.
|
|
|
|
|
2017-02-13 10:55:53 +08:00
|
|
|
````jsx
|
2015-10-28 20:55:49 +08:00
|
|
|
import { Switch, Button } from 'antd';
|
2015-07-13 16:51:56 +08:00
|
|
|
|
2017-02-20 22:15:52 +08:00
|
|
|
class App extends React.Component {
|
|
|
|
state = {
|
|
|
|
disabled: true,
|
|
|
|
}
|
2018-06-27 15:55:04 +08:00
|
|
|
|
2017-02-20 22:15:52 +08:00
|
|
|
toggle = () => {
|
2015-07-13 16:51:56 +08:00
|
|
|
this.setState({
|
2016-05-11 09:32:33 +08:00
|
|
|
disabled: !this.state.disabled,
|
2015-07-13 16:51:56 +08:00
|
|
|
});
|
2017-02-20 22:15:52 +08:00
|
|
|
}
|
2018-06-27 15:55:04 +08:00
|
|
|
|
2015-07-13 16:51:56 +08:00
|
|
|
render() {
|
2016-01-07 16:29:12 +08:00
|
|
|
return (
|
|
|
|
<div>
|
2017-09-27 22:32:49 +08:00
|
|
|
<Switch disabled={this.state.disabled} defaultChecked />
|
2016-10-21 11:09:24 +08:00
|
|
|
<br />
|
2016-01-07 16:29:12 +08:00
|
|
|
<Button type="primary" onClick={this.toggle}>Toggle disabled</Button>
|
|
|
|
</div>
|
|
|
|
);
|
2017-02-20 22:15:52 +08:00
|
|
|
}
|
|
|
|
}
|
2015-07-13 16:51:56 +08:00
|
|
|
|
2017-02-20 22:15:52 +08:00
|
|
|
ReactDOM.render(<App />, mountNode);
|
2015-07-13 16:51:56 +08:00
|
|
|
````
|