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

36 lines
666 B
Markdown
Raw Normal View History

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:&nbsp;
<Switch defaultChecked={false} onChange={onChange}/><br/>&nbsp;
</p>
<p>
disabled:&nbsp;
<Switch disabled/><br/>&nbsp;
</p>
<p>
children:&nbsp;
<Switch checkedChildren="开" unCheckedChildren="关"/><br/>&nbsp;
</p>
<p>
icon children:&nbsp;
<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
````