You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
666 B

10 years ago
# 用法示例
10 years ago
- order: 0
10 years ago
switch 用法
10 years ago
---
````jsx
var Switch = antd.Switch;
var container = document.getElementById('components-switch-demo-basic');
function onChange(checked){
console.log('switch to ' + checked);
}
10 years ago
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);
10 years ago
````