vuex process

Personal understanding:

  1, actions call interface call the method $ store.state.dispatch ( "method name", the parameters of mass participation)

  const actions ={

  

  async method name ({commit}, with a reference parameter passing) {

  const data = await axios.get ( "method name", parameter) {

  params:{

    parameter

    }

   })

  commit. ( "mutations of the method name", data) 

 }

}

 

  2、const state = {

  Define the parameters needed

}

You need to change the state status by mutations, calling the action required

  3 consists muataions = {

  Method name (state, came parameter) {

   state. To change the parameter = parameter coming. parameter to be changed

  }

}

 

export default {

  state,actions,mutatioins,module,getteer

}

-------------------------------------split line----------- ----------------------------------

Guess you like

Origin www.cnblogs.com/yangruifan/p/11791424.html