码迷,mamicode.com
首页 > 其他好文 > 详细

vuex配置

时间:2019-09-11 09:22:19      阅读:94      评论:0      收藏:0      [点我收藏+]

标签:class   timeout   mount   config   ++   use   route   div   add   

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配置

标签:class   timeout   mount   config   ++   use   route   div   add   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!