this.$store.commit('loginStatus', 1);

this.$store.dispatch('isLogin', true);

规范的使用方式:

// 以载荷形式
store.commit('increment',{
amount: 10 //这是额外的参数
})

// 或者使用对象风格的提交方式
store.commit({
type: 'increment',
amount: 10 //这是额外的参数
})

主要区别:
dispatch:含有异步操作,数据提交至 actions ,可用于向后台提交数据

this.$store.dispatch('isLogin', true);

commit:同步操作,数据提交至 mutations ,可用于读取用户信息写到缓存里

this.$store.commit('loginStatus', 1);

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-10
  • 2022-12-23
  • 2021-08-28
猜你喜欢
  • 2023-03-13
  • 2022-12-23
  • 2023-03-13
  • 2022-12-23
  • 2022-12-23
  • 2021-06-30
相关资源
相似解决方案