Answer the question
In order to leave comments, you need to log in
Why does Vuex work “randomly” and how to properly get state from it?
There is storage :
import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
export default new Vuex.Store({
state: {
userData: ''
},
mutations: {
setData: function(state, data) {
state.userData = data
}
},
actions: {
},
modules: {
}
})
export default {
name: 'Profile',
data() {
return {
userData: this.$store.state.userData
}
},
}
Answer the question
In order to leave comments, you need to log in
You need to create getters like this:
getters: {
userData: state => {
return state.UserData;
}
this.$store.getter.userData
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question