[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:
neverland
2017-10-12 07:06:27 -05:00
committed by GitHub
parent 47576ec47c
commit 9084a662c3
24 changed files with 858 additions and 293 deletions

View File

@@ -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);
}
}
}