Last active
September 21, 2017 16:22
-
-
Save lmiller1990/c1ad633d0a6ec98f437e4520e40446ef to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<div id="app"> | |
{{ $store.state.a.name }} | |
{{ $store.state.a.initData }} | |
</div> | |
</template> | |
<script> | |
export default { | |
name: 'app', | |
} | |
</script> | |
<style> | |
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Vue from 'vue' | |
import App from './App.vue' | |
import store from './store' | |
new Vue({ | |
el: '#app', | |
store, | |
render: h => h(App) | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Vue from 'vue' | |
import Vuex from 'vuex' | |
Vue.use(Vuex) | |
const moduleA = { | |
state: { | |
name: 'module A', | |
initData: '' | |
}, | |
mutations: { | |
INIT (state, payload) { | |
state.initData = 'Initialized A' | |
} | |
} | |
} | |
const moduleB = { | |
state: { | |
name: 'module B', | |
initData: '' | |
}, | |
mutations: { | |
INIT (state, payload) { | |
state.initData = 'Initialized B' | |
} | |
} | |
} | |
const initPlugin = store => { | |
store.commit('INIT') | |
} | |
export default new Vuex.Store({ | |
state: {}, | |
mutations: {}, | |
modules: { | |
a: moduleA, | |
b: moduleB | |
}, | |
plugins: [initPlugin] | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment