disabled.md 559 字节
Newer Older
B
Benjy Cui 已提交
1 2 3 4
---
order: 1
title: 不可用
---
A
afc163 已提交
5

Y
yiminghe 已提交
6
Switch 失效状态。
A
afc163 已提交
7 8

````jsx
A
afc163 已提交
9
import { Switch, Button } from 'antd';
A
afc163 已提交
10

A
afc163 已提交
11
const Test = React.createClass({
A
afc163 已提交
12 13
  getInitialState() {
    return {
Y
yiminghe 已提交
14
      disabled: true
15
    };
A
afc163 已提交
16
  },
17
  toggle() {
A
afc163 已提交
18 19 20 21 22
    this.setState({
      disabled: !this.state.disabled
    });
  },
  render() {
23 24 25 26 27 28 29 30
    return (
      <div>
        <Switch disabled={this.state.disabled} />
        <br />
        <br />
        <Button type="primary" onClick={this.toggle}>Toggle disabled</Button>
      </div>
    );
A
afc163 已提交
31 32 33
  }
});

34
ReactDOM.render(<Test />, mountNode);
A
afc163 已提交
35
````