vant/packages/switch/index.vue
neverland ffa3fddfae
[bugfix] remove unnecessary props (#323)
* fix: Tabbar icon line-height

* [new feature] progress add showPivot prop

* [new feature] TabItem support vue-router

* [new feature] update document header style

* [Doc] add toast english ducoment

* [bugfix] Search box-sizing wrong

* [Doc] update vant-demo respo

* [Doc] translate theme & demo pages

* [Doc] add Internationalization document

* [bugfix] remove unnecessary props
2017-11-16 03:12:13 -06:00

36 lines
745 B
Vue

<template>
<div class="van-switch" :class="[`van-switch--${value ? 'on' : 'off'}`, { 'van-switch--disabled': disabled }]" @click="toggleState">
<div class="van-switch__node van-hairline-surround">
<van-loading v-if="loading" class="van-switch__loading" />
</div>
<div class="van-switch__bg" />
</div>
</template>
<script>
import Loading from '../loading';
export default {
name: 'van-switch',
components: {
[Loading.name]: Loading
},
props: {
value: Boolean,
loading: Boolean,
disabled: Boolean
},
methods: {
toggleState() {
if (!this.disabled && !this.loading) {
this.$emit('input', !this.value);
this.$emit('change', !this.value);
}
}
}
};
</script>