2015-07-09 21:05:33 +08:00
|
|
|
# 用法示例
|
2015-07-08 19:47:45 +08:00
|
|
|
|
|
|
|
- order: 0
|
|
|
|
|
2015-07-09 21:05:33 +08:00
|
|
|
switch 用法
|
2015-07-08 19:47:45 +08:00
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
````jsx
|
|
|
|
var Switch = antd.Switch;
|
|
|
|
var container = document.getElementById('components-switch-demo-basic');
|
|
|
|
|
|
|
|
function onChange(checked){
|
|
|
|
console.log('switch to ' + checked);
|
|
|
|
}
|
|
|
|
|
2015-07-09 21:05:33 +08:00
|
|
|
React.render(<div>
|
|
|
|
<p>
|
|
|
|
simple:
|
|
|
|
<Switch defaultChecked={false} onChange={onChange}/><br/>
|
|
|
|
</p>
|
|
|
|
<p>
|
|
|
|
disabled:
|
|
|
|
<Switch disabled/><br/>
|
|
|
|
</p>
|
|
|
|
<p>
|
|
|
|
children:
|
|
|
|
<Switch checkedChildren="开" unCheckedChildren="关"/><br/>
|
|
|
|
</p>
|
|
|
|
<p>
|
|
|
|
icon children:
|
|
|
|
<Switch checkedChildren={<i className="anticon anticon-check"></i>} unCheckedChildren={<i className="anticon anticon-cross"></i>}/>
|
|
|
|
</p>
|
|
|
|
</div>, container);
|
2015-07-08 19:47:45 +08:00
|
|
|
````
|