Nuxt.js Vuex / The console.log in mutation can see the future state?

Viewed 406

I am using Nuxt.js and module Vuex to build my app, but I have a question

I have a button which can trigger test() function

page/login.vue

<button @click="test">Test</button>

methods: {
  test() {
    this.$store.commit('user/test', { value: 'after' })
  }
}

store/user.js

export const state = () => ({
  hello: 'before'
})

export const mutations = {
  test(state, { value }) {
    console.log(state) // <- when I trying to console.log here, the value of hello was 'after'
    state.hello = value
  }
}

Did I miss something or that's normal?

0 Answers
Related