Static GitHub Issues

[2848] [DOCS] bug

prev: Using hiq postcss library with nuxt
next: Multiple error layouts

Hello, Please go to https://nuxtjs.org/guide/vuex-store#modules-mode. Example for modules does not work because it is missing with namespaced: true, for todos module.

new Vuex.Store({
  state: { counter: 0 },
  mutations: {
    increment (state) {
      state.counter++
    }
  },
  modules: {

    todos: {
      namespaced: true, // <-------------<=== this line is missing
      state: {
        list: []
      },
      mutations: {
        add (state, { text }) {
          state.list.push({
            text,
            done: false
          })
        },
        remove (state, { todo }) {
          state.list.splice(state.list.indexOf(todo), 1)
        },
        toggle (state, { todo }) {
          todo.done = !todo.done
        }
      }
    }
  }
})

Without it methods become global and they are not accessible by their namespace. IE 'todos/toggle'.

Best regards, Arczik!

<!--cmty--><!--cmty_prevent_hook--><div align="right"><sub><em>This question is available on <a href="https://nuxtjs.cmty.io">Nuxt.js</a> community (<a href="https://nuxtjs.cmty.io/nuxt/nuxt.js/issues/c2474">#c2474</a>)</em></sub></div>