组件之间数据共享

组件之间的数据同步与共享

如何在组件中使用mutations内的方法?

methods: {
     addOne () {
       this.$store.commit('increment', this.price)
     },
     minusOne () {
       this.$store.commit('decrement', this.price)
     }
   }

如何在组件中使用actions内的方法?

methods: {
     addOne () {
       this.$store.dispatch('increase', this.price)
     }
   }

猜你喜欢

转载自www.cnblogs.com/NeryXJ/p/9930011.html