init
init
This commit is contained in:
parent
5762337416
commit
7fa943eb39
128 changed files with 51042 additions and 1 deletions
2
components/switch/index.js
Normal file
2
components/switch/index.js
Normal file
|
@ -0,0 +1,2 @@
|
|||
import Switch from './switch.vue';
|
||||
export default Switch;
|
56
components/switch/switch.vue
Normal file
56
components/switch/switch.vue
Normal file
|
@ -0,0 +1,56 @@
|
|||
<template>
|
||||
<span :class="wrapClasses" @click="toggle">
|
||||
<span :class="innerClasses">
|
||||
<slot name="open" v-if="checked"></slot>
|
||||
<slot name="close" v-if="!checked"></slot>
|
||||
</span>
|
||||
</span>
|
||||
</template>
|
||||
<script>
|
||||
import { oneOf } from '../../utils/assist';
|
||||
|
||||
const prefixCls = 'ivu-switch';
|
||||
|
||||
export default {
|
||||
props: {
|
||||
checked: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
disabled: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
size: {
|
||||
validator (value) {
|
||||
return oneOf(value, ['small']);
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
wrapClasses () {
|
||||
return [
|
||||
`${prefixCls}`,
|
||||
{
|
||||
[`${prefixCls}-checked`]: this.checked,
|
||||
[`${prefixCls}-disabled`]: this.disabled,
|
||||
[`${prefixCls}-${this.size}`]: !!this.size
|
||||
}
|
||||
]
|
||||
},
|
||||
innerClasses () {
|
||||
return `${prefixCls}-inner`;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
toggle () {
|
||||
if (this.disabled) {
|
||||
return false;
|
||||
}
|
||||
|
||||
this.checked = !this.checked;
|
||||
this.$emit('on-change', this.checked);
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue