ant-design/components/switch/demo/disabled.md

42 lines
608 B
Markdown
Raw Normal View History

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`.
2015-07-13 16:51:56 +08:00
````jsx
import { Switch, Button } from 'antd';
2015-07-13 16:51:56 +08:00
const Test = React.createClass({
2015-07-13 16:51:56 +08:00
getInitialState() {
return {
2016-05-11 09:32:33 +08:00
disabled: true,
};
2015-07-13 16:51:56 +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
});
},
render() {
return (
<div>
<Switch disabled={this.state.disabled} />
<Button type="primary" onClick={this.toggle}>Toggle disabled</Button>
</div>
);
2016-05-11 09:32:33 +08:00
},
2015-07-13 16:51:56 +08:00
});
ReactDOM.render(<Test />, mountNode);
2015-07-13 16:51:56 +08:00
````