官方:https://vuex.vuejs.org/zh/guide/

有说明:

为了在 Vue 组件中访问 this.$store property,你需要为 Vue 实例提供创建好的 store。Vuex 提供了一个从根组件向所有子组件,以 store 选项的方式“注入”该 store 的机制:

所以已经注入,不需要用  Vue.prototype.$store = store 重复挂载

直接使用 this.$store

methods: {
  increment() {
    this.$store.commit('increment')
    console.log(this.$store.state.count)
  }
}

 

 

 

 

 

 

 

 

.

相关文章:

  • 2022-12-23
  • 2021-08-11
  • 2021-12-24
  • 2021-08-26
  • 2021-12-09
  • 2022-12-23
  • 2022-12-23
  • 2021-11-02
猜你喜欢
  • 2022-12-23
  • 2021-10-30
  • 2022-12-23
  • 2021-05-19
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案