vuex 未完成
2021-11-25 23:11:44   5  举报             
     
         
 123
    作者其他创作
 大纲/内容
         [ store/index.js ]  1.   Vue.use(Vuex)   2.  const store = new Vuex.Store( {  }  )    3.   export default store        [      main.js      ]  1.   import store from ' @/store'        2.   new Vue  (  {  store  }  )
  mutations(改变state唯一途径)
  getters(计算变量)
  actions(异步任务途径)
  1.直接 : this.$store.state.变量名2.映射 : 1 -   import { mapState } from ' vuex '     2 -   在computed中 : ...mapState( [ ' 变量名 ' ] )
  state(公共变量)
  任意组件
  1.直接 : this.$store.getters.变量名2.映射 : 1 -   import { mapGetters } from ' vuex '     2 -   在computed中 : ...mapGetters( [ ' 变量名 ' ] )
  new出的store对象
   
 
 
 
 
  0 条评论
 下一页
  
   
  
  
  
  
  
  
  
  
 