step1

npm  install  --save  vuex

step2

他的用法与vue-router差不多,main.js中,通过Vue.use(),使用;然后new Vuex.store();然后new Vue( store:store):

vue(6)-vuex

step3

这样在任何组件里,可以通过{{$store.state.city}}来使用

vue(6)-vuex

同样,在任何组件里可以通过this.$store.commit(..,..)来执行mutations:

vue(6)-vuex

相关文章:

  • 2021-06-12
  • 2022-02-21
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-29
猜你喜欢
  • 2021-12-07
  • 2021-04-22
  • 2021-12-03
  • 2022-12-23
  • 2021-08-07
  • 2021-08-03
  • 2021-07-07
相关资源
相似解决方案