vuex的相关知识

首先是vuex的四大将

1.state

主要是保存数据的,通过this.$store.state获取

2.getters

监听state中的值的变化,返回计算后的结果。getter的返回值会根据它的依赖被缓存起来

3.mutation

是修改store中的值得唯一方式

4.actions是修改的状态或者数据进行提交。

官方建议提交一个actions,在actions中提交mutations再去修改状态值。

this.$store.dispatch('add1')
//this.$store.commit('add1')

posted @ 2020-11-15 18:33  星雨,恒奋斗,过客  阅读(62)  评论(0编辑  收藏  举报