Answer the question
In order to leave comments, you need to log in
Vuetify switch with Vuex?
<v-switch v-model="this.isPushNotifyEnabled"
:color="switchColor"
inset
/>
import {mapGetters} from 'vuex';
import {SESSION} from '../../store/modulesNames';
export default {
data: () => (
{
// isPushNotifyEnabled: false,
}
),
computed: {
switchColor () {
return '#bdd730';
},
...mapGetters(
SESSION,
{
isPushNotificationEnabled: `isPushNotificationEnabled`,
}
),
isPushNotifyEnabled: {
get: function () {
return this.isPushNotificationEnabled;
},
set: function (newValue) {
console.log(newValue)
},
},
},
vue.runtime.esm.js?2b0e:619 [Vue warn]: Cannot set reactive property on undefined, null, or primitive value: null
warn @ vue.runtime.esm.js?2b0e:619
set @ vue.runtime.esm.js?2b0e:1069
callback @ settings.vue?81dc:79
invokeWithErrorHandling @ vue.runtime.esm.js?2b0e:1854
invoker @ vue.runtime.esm.js?2b0e:2179
invokeWithErrorHandling @ vue.runtime.esm.js?2b0e:1854
Vue.$emit @ vue.runtime.esm.js?2b0e:3888
Vue.<computed> @ backend.js:1793
set @ VInput.ts?5bf9:103
onChange @ index.ts?0230:159
invokeWithErrorHandling @ vue.runtime.esm.js?2b0e:1854
invoker @ vue.runtime.esm.js?2b0e:2179
original._wrapper @ vue.runtime.esm.js?2b0e:6917
client.js?06a0:77 TypeError: Cannot use 'in' operator to search for 'isPushNotifyEnabled' in null
at Proxy.set (vue.runtime.esm.js?2b0e:1076)
at callback (settings.vue?81dc:79)
at invokeWithErrorHandling (vue.runtime.esm.js?2b0e:1854)
Answer the question
In order to leave comments, you need to log in
<template>
<v-switch
v-model="isNotifyEnabled"
:label="`Switch status: ${isNotifyEnabled.toString()}`"
></v-switch>
</template>
import Vue from "vue";
import Vuex from "vuex";
Vue.use(Vuex);
export default new Vuex.Store({
state: {
isNotifyEnabled: false
},
mutations: {
updateNotifyEnabled(state, value) {
state.isNotifyEnabled = value;
}
},
});
computed: {
isNotifyEnabled: {
get() {
return this.$store.state.isNotifyEnabled;
},
set(value) {
this.$store.commit("updateNotifyEnabled", value);
}
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question