首页 > 其他 > 详细

vuex配置

时间:2019-09-11 10:05:48      阅读:81      评论:0      收藏:0      [点我收藏+]
import Vue from ‘vue‘
import App from ‘./App.vue‘
import router from ‘./router‘
import store from ‘./store‘
import Vuex from ‘vuex‘

 Vue.use(Vuex)
 const myStore = new Vuex.Store({
    state :{
      count:0
    },
    getters:{
       getCount(state){
            return ‘当前最新的count值是:‘+state.count
       }
    },
    mutations:{
       add(state){
          state.count++
       }
    },
    actions:{
        mody(e){
            setTimeout( ()=>{
              e.commit(‘add‘)
            },2000 )
        }
    }
    
})

Vue.config.productionTip = false

new Vue({
  router,
  store:myStore,
  render: h => h(App)
}).$mount(‘#app‘)

 

vuex配置

原文:https://www.cnblogs.com/javascript9527/p/11504270.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!