Skip to content

Commit

Permalink
Fix for Vue3 - Now it works with Vue3 drewjbartlett#27
Browse files Browse the repository at this point in the history
  • Loading branch information
hasinhayder committed Jan 16, 2021
1 parent 52a19a1 commit c93cf1a
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/switches.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<span v-if="!label && !value" v-text="textDisabled"></span>
</span>

<input type="checkbox" :disabled="disabled" @change="trigger" :checked="value" v-model="value">
<input type="checkbox" :disabled="disabled" @change="trigger" :checked="modelValue" >

<div></div>
</label>
Expand All @@ -16,13 +16,12 @@
export default {
name: 'switches',
props: {
typeBold: {
default: false
},
value: {
modelValue:{
default: false
},
Expand Down Expand Up @@ -57,24 +56,24 @@ export default {
mounted () {
if(this.emitOnMount) {
this.$emit('input', this.value)
this.$emit('update:modelValue', this.modelValue)
}
},
methods: {
trigger (e) {
this.$emit('input', e.target.checked)
this.$emit('update:modelValue', e.target.checked)
}
},
computed: {
classObject () {
const { color, value, theme, typeBold, disabled } = this;
const { color, modelValue, theme, typeBold, disabled } = this;
return {
'vue-switcher' : true,
['vue-switcher--unchecked'] : !value,
['vue-switcher--unchecked'] : !modelValue,
['vue-switcher--disabled'] : disabled,
['vue-switcher--bold']: typeBold,
['vue-switcher--bold--unchecked']: typeBold && !value,
Expand Down

0 comments on commit c93cf1a

Please sign in to comment.