vuex实现数据共享

vuex用于实现大型数据
共用一个数据,当一个组件数据发生变化的时候,另一个组件数据也会跟着变化

全局的共用数据都放在state里面

组件vue components改数据必须调用actions - mutations-state

mutations

Actions处理异步操作或批量的同步操作

可以调用 s t o r e t h i s . store 例如:this. store.state.city

ps:所有的js文件都要在main.js中引入,在main.js中的实例中要进行挂载,例如:store

发布了9 篇原创文章 · 获赞 6 · 访问量 51

猜你喜欢

转载自blog.csdn.net/weixin_46137478/article/details/104722313