Vuex是做什么的



单界面的状态管理





多界面状态管理


小案例


挂载到vue实例中


使用Vuex的count



Vuex核心概念

state单一状态树

Getters基本使用

getters:{
greateAgesCount:state=>{
return state.students.filter(s=>s.age>=20).length
}
},
computed:{
getGreaterAgeCount(){
return this.$store.state.students.fileter(age=>age>=20).length
}
}
Getters作为参数和传递参数




Mutation状态更新


传递参数

提交风格

响应规则



常量类型





Muations同步函数




Action的基本定义

Action分发

Action返回的Promise


Module

Module局部状态

Action的写法


转载:https://blog.csdn.net/qq_41961239/article/details/117217700
查看评论