search

Home  >  Q&A  >  body text

javascript - What does commit mutation mean in actions in vuex? I don’t quite understand it.

習慣沉默習慣沉默2756 days ago730

reply all(2)I'll reply

  • 高洛峰

    高洛峰2017-05-19 10:45:29

    Trigger the increment in actions, context.commit("increment") triggers the increment function in mutations, this is the process

    reply
    0
  • 大家讲道理

    大家讲道理2017-05-19 10:45:29

    I am also new to VuexNot long ago, let me briefly talk about my understanding.

    Store理解为一个仓库,action是一次操作,mutation是让仓库中存储的东西产生某种变化的方式,state is the current status of the stored thing.

    One operation may need to change the data, and another operation also needs to make the same change to the data. Then this change can be extracted and called a mutation,这样,通过commit触发指定的mutation. There is no need to mix it with the code that operates the business, resulting in code The result is clutter and poor maintainability.

    reply
    0
  • Cancelreply