## Switch
### Install
``` javascript
import { Switch } from 'vant';
Vue.component(Switch.name, Switch);
```
### Usage
#### Basic Usage
:::demo Basic Usage
```html
```
```javascript
export default {
data() {
return {
checked: true
};
}
};
```
:::
#### Disabled
:::demo Disabled
```html
```
:::
#### Loading
:::demo Loading
```html
```
:::
#### Advanced usage
:::demo Advanced usage
```html
```
```js
export default {
data() {
return {
checked2: true
};
},
methods: {
onInput(checked) {
Dialog.confirm({
title: 'Confirm',
message: 'Are you sure to toggle switch?'
}).then(() => {
this.checked2 = checked;
});
}
}
};
```
:::
### API
| Attribute | Description | Type | Default | Accepted Values |
|-----------|-----------|-----------|-------------|-------------|
| v-model | Check status of Switch | `Boolean` | `false` | - |
| loading | Whether to show loading icon | `Boolean` | `false` | - |
| disabled | Disable switch | `Boolean` | `false` | - |
### Event
| Event | Description | Parameters |
|-----------|-----------|-----------|
| change | Triggered when check status changed | checked: is switch checked |