普歌-智音团队 vuex里State,Mutation,Action,Getter的使用
1.State定义:State提供唯一的公共源,所有共享的数据都要统一放 到Store的State中进行存储
2.Mutation定义:用于变更Store的数据
3.Action定义:用于处理异步任务
4.Getter定义:用于对Store中数据进行加工处理成新的数据
State的用法
//创建store 的数据源,提供唯一公共数据
const store =new Vuex.Store({
State:{ count: 0 }
})
组件访问State中数据的第一种方式:
this.
原创
2020-09-02 01:00:55 ·
98 阅读 ·
0 评论