Questions tagged [vuex]

Vuex is a state management pattern + library for Vue.js applications. It serves as a centralized store for all the components in an application, with rules ensuring that the state can only be mutated in a predictable fashion.

Vuex is a data management library by the creator of Vue.js. It is designed to help build larger applications in a more maintainable way by following principles similar to those made popular by Facebook’s Flux library (and subsequent iterations by community like redux).

Principles

  • Terse
  • Testable
  • Reactive
  • Single State Tree
  • Hot Reloading
  • Time Travel (with vue-devtools support)

GitHub: https://github.com/vuejs/vuex Documentation: https://vuex.vuejs.org/en/

7756 questions
55
votes
1 answer

Vuex | How to commit a global mutation in a module action?

I have an action in a namespaced module and a global mutation (i.e. not in a module). I would like to be able to commit the global mutation inside the action. // Global mutation export default { globalMutation (state, payload) { ... } } //…
Julien Le Coupanec
  • 7,742
  • 9
  • 53
  • 67
53
votes
1 answer

Vuex: Skipping Action and committing Mutation directly from Component

In vue.js app, using vuex as state management store, I need to simply change the value of a property in vuex. For this I can follow two methods: Dispatch an action method, which will further commit mutation, which eventually will change the…
Faisal Khurshid
  • 1,869
  • 3
  • 21
  • 27
53
votes
7 answers

accessing vuex store in js file

Just like in main.js, I'm trying to access my store from a helper function file: import store from '../store' let auth = store.getters.config.urls.auth But it logs an error: Uncaught TypeError: Cannot read property 'getters' of undefined. I have…
Elena Maximova
  • 916
  • 1
  • 8
  • 15
52
votes
1 answer

Accessing rootState in Vuex getter

How do you access rootState in getters? const getters = { getParams: rootState => { return rootState.route.params }, } The above doesn't work. How is this done?
softcode
  • 4,358
  • 12
  • 41
  • 68
50
votes
7 answers

Should we use v-model to modify Vuex store?

Hello I am beginner in Vue and I do have a problem that's really bugging me. I am wondering should we use v-model directive to modify vuex store? Vuex says that we should modify vuex store only by mutations but v-model makes everything easier and…
Krzysztof Kaczyński
  • 4,412
  • 6
  • 28
  • 51
49
votes
8 answers

Is Vuex Store accessible from console or from client's browser?

I'm building this Vue 2 app, and I keep reading that one should use Vuex State management, in the beginning I didn't quite understand it's concept, but now after playing around with Vue, I can see it's a most for a larger app. But my question is…
Marketingexpert
  • 1,421
  • 4
  • 21
  • 34
48
votes
4 answers

Vue.js: Nuxt error handling

Struggling a bit to set up error handling with vuex. There seems to be quite a few ways to do so and little documentation on proper error handling. I've been experimenting with four alternatives, though I haven't found a satisfying solution…
nomadoda
  • 4,561
  • 3
  • 30
  • 45
46
votes
4 answers

How to correctly use Vue JS watch with lodash debounce

I'm using lodash to call a debounce function on a component like so: ... import _ from 'lodash'; export default { store, data: () => { return { foo: "", } }, watch: { searchStr:…
Artur Grigio
  • 5,185
  • 8
  • 45
  • 65
45
votes
11 answers

Axios - Remove headers Authorization in 1 call only

How can I remove the axios.defaults.headers.common.Authorization only in 1 call? I'm setting the default for all the calls to my domain but I have 1 call that I make on another domain and if the token is passed the call gives me an error, when…
user7021169
43
votes
10 answers

Vuex - Do not mutate vuex store state outside mutation handlers

Why do I get this error: Error [vuex] Do not mutate vuex store state outside mutation handlers. What does it mean? It happens when I try to type in the edit input file. pages/todos/index.vue