I'm trying to do everytime v-switch
is changed, switchPackage
is changed to either true
or false
. Nothing appears in console, when i test. Where did i go wrong?
component
<v-switch v-model="switchPackage" @change="switchPackage!=switchPackage" inset>
</v-switch>
script
export default class MembershipProducts extends Vue {
@Prop() readonly products!: Object;
data() {
return {
switchPackage:false
}
};
watch() {
switchPackage:(newValue:number) => {
console.log('switch toggled to ' newValue);
}
};
}
CodePudding user response:
My guess is that the v-switch
component automatically sets the v-model (switchPackage
) on click but you instantly reset it back with @change="switchPackage!=switchPackage"
. Just remove the @change
event and it should work.