2016-03-31 09:40:55 +08:00
|
|
|
---
|
|
|
|
order: 0
|
2016-07-26 09:17:46 +08:00
|
|
|
title:
|
|
|
|
zh-CN: 基本
|
|
|
|
en-US: Basic
|
2016-03-31 09:40:55 +08:00
|
|
|
---
|
2015-07-08 19:47:45 +08:00
|
|
|
|
2016-07-26 09:17:46 +08:00
|
|
|
## zh-CN
|
|
|
|
|
2015-07-13 16:51:56 +08:00
|
|
|
最简单的用法。
|
2015-07-08 19:47:45 +08:00
|
|
|
|
2016-07-26 09:17:46 +08:00
|
|
|
## en-US
|
|
|
|
|
|
|
|
The most basic usage.
|
|
|
|
|
2022-05-19 09:46:26 +08:00
|
|
|
```tsx
|
2015-10-28 20:55:49 +08:00
|
|
|
import { Switch } from 'antd';
|
2022-05-23 14:37:16 +08:00
|
|
|
import React from 'react';
|
2015-07-08 19:47:45 +08:00
|
|
|
|
2022-05-19 09:46:26 +08:00
|
|
|
const onChange = (checked: boolean) => {
|
2016-02-17 18:04:42 +08:00
|
|
|
console.log(`switch to ${checked}`);
|
2022-05-19 09:46:26 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
const App: React.FC = () => <Switch defaultChecked onChange={onChange} />;
|
2015-07-08 19:47:45 +08:00
|
|
|
|
2022-05-19 09:46:26 +08:00
|
|
|
export default App;
|
2019-05-07 14:57:32 +08:00
|
|
|
```
|
2016-06-15 14:13:38 +08:00
|
|
|
|
|
|
|
<style>
|
2019-12-25 21:54:21 +08:00
|
|
|
.code-box-demo .ant-switch {
|
2016-06-15 14:13:38 +08:00
|
|
|
margin-bottom: 8px;
|
|
|
|
}
|
2017-12-15 13:47:46 +08:00
|
|
|
</style>
|