Vue.use(Vuex)
//init store
const store = new Vuex.Store({
state: {
input1 : 'blank'
},
mutations: {
updateInput (state, value) {
state.input1 = value;
}
}
});
Vue.use(VueRouter);
const Home = {
template : '
Start
start'
};
const Step = {
template : 'Value
save{{input1}}',
methods : {
updateInput(e) {
this.$store.commit('updateInput', e.target.value);
}
},
computed : {
input1() {
return this.$store.state.input1;
}
}
};
const Result = {
template : 'result : {{input1}}
',
computed : {
input1() {
return this.$store.state.input1;
}
}
};
//define routes
const routes = [
{ path: '/', name: 'Home', component: Home },
{ path: '/step', name: 'Step', component: Step },
{ path: '/result', name: 'Result', component: Result }
];
//init app
const app = new Vue({
router: new VueRouter({ routes }),
store,
template: ''
}).$mount('#app')