mirror of
https://github.com/youzan/vant.git
synced 2025-10-19 18:14:13 +00:00
[Document] add form components english document (#199)
* [Document] add english document of Checkbox * [Document] add english document of Field * [Document] add english document of NumberKeyboard * [bugfix] NumberKeyboard should not dispaly title when title is empty * [Document] add english document of PasswordInput * [Document] add english document of Radio * [document] add english document of Switch * [bugfix] remove redundent styles in english document * [Document] fix details * fix Switch test cases
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<div class="van-switch" :class="[`van-switch--${checked ? 'on' : 'off'}`, { 'van-switch--disabled': disabled }]" @click="toggleState">
|
||||
<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>
|
||||
@@ -12,39 +12,22 @@ import Loading from '../loading';
|
||||
|
||||
export default {
|
||||
name: 'van-switch',
|
||||
|
||||
components: {
|
||||
[Loading.name]: Loading
|
||||
},
|
||||
|
||||
props: {
|
||||
value: Boolean,
|
||||
disabled: Boolean,
|
||||
loading: Boolean,
|
||||
onChange: Function
|
||||
disabled: Boolean
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
checked: this.value
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
checked(val) {
|
||||
this.$emit('input', val);
|
||||
},
|
||||
|
||||
value(val) {
|
||||
this.checked = val;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
/*
|
||||
* 开关状态交互。
|
||||
*/
|
||||
toggleState: function() {
|
||||
if (this.disabled || this.loading) return;
|
||||
if (this.onChange) {
|
||||
this.onChange(!this.checked);
|
||||
} else {
|
||||
this.checked = !this.checked;
|
||||
toggleState() {
|
||||
if (!this.disabled && !this.loading) {
|
||||
this.$emit('input', !this.value);
|
||||
this.$emit('change', !this.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user