两个方法都是传值给vuex的mutation改变state

dispatch异步操作,数据提交至 actions ,可用于向后台提交数据

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

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

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

注:必须要用commit(‘SET_TOKEN’, tokenV)调用mutations里的方法,才能在store存储成功。

Logo

前往低代码交流专区

更多推荐