search

Home  >  Q&A  >  body text

javascript - vuex, getters are only executed once, data update getters data is not updated

I encountered a problem in the project. I used vuex to manage state and data. Actions->mutations->state uses this method to modify state data. Getters obtain data. In the component, computed updates the obtained data. Problem The data is updated in mutations, but not in getters, and why is the getters only executed once?

In store:

In component:

Triggering the submitForm() method will request data

曾经蜡笔没有小新曾经蜡笔没有小新2736 days ago1538

reply all(4)I'll reply

  • 扔个三星炸死你

    扔个三星炸死你2017-06-28 09:27:43

    getters less return

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-06-28 09:27:43

    I suggest you take a good look at the official vuex documentation. Mutation changes an attribute of the state, not directly changing the state itself

    reply
    0
  • 淡淡烟草味

    淡淡烟草味2017-06-28 09:27:43

    The problem is solved. There are several solutions. One is to use mapState, and the other is to change this
    into an assignment form

    reply
    0
  • 为情所困

    为情所困2017-06-28 09:27:43

    @Msevensun My current situation is the same as yours, but when I use mapState, why does it still print the initial data instead of the asynchronously changed data?

    reply
    0
  • Cancelreply