switch docs

This commit is contained in:
cookfront
2017-03-31 20:47:09 +08:00
parent 4d974ce619
commit 4e9126e352
4 changed files with 101 additions and 84 deletions

View File

@@ -18,7 +18,7 @@ import ZanLoading from 'packages/loading';
* @param {boolean} [loading=false] - loading状态
*
* @example
* <zan-switch checked="true" disabled="false"></zan-switch>
* <zan-switch :checked="true" :disabled="false"></zan-switch>
*/
export default {
name: 'zan-switch',
@@ -26,23 +26,17 @@ export default {
'zan-loading': ZanLoading
},
props: {
checked: {
type: Boolean,
default: false
},
disabled: {
type: Boolean,
default: false
},
loading: {
type: Boolean,
default: false
}
checked: Boolean,
disabled: Boolean,
loading: Boolean
},
computed: {
switchStates: function() {
const switchStates = ['zan-switch--' + (this.checked ? 'on' : 'off'),
'zan-switch--' + (this.disabled ? 'disabled' : '')];
const switchStates = ['zan-switch--' + (this.checked ? 'on' : 'off')];
if (this.disabled) {
switchStates.push('zan-switch--disabled');
}
return switchStates;
}