Skip to content

Instantly share code, notes, and snippets.

@BrianRosamilia
Created July 27, 2017 17:44
Show Gist options
  • Save BrianRosamilia/d1785ea423cce4e48ffe8b63b3b614ba to your computer and use it in GitHub Desktop.
Save BrianRosamilia/d1785ea423cce4e48ffe8b63b3b614ba to your computer and use it in GitHub Desktop.
Semi Minimal Vue/Vuex/Vue-router boilerplate
const db = new Vuex.Store({
state: {
name : 'test',
},
getters: {
name: state => {
return state.name;
}
},
mutations: {
setName(state, name){
state.name = name;
}
}
});
const homeComponent = Vue.extend({
name: 'home',
template: document.querySelector('#home').innerHTML,
store: db,
mounted: function(){
document.getElementById('brand').focus();
},
computed: {
name: function(){ return this.$store.getters.name },
},
methods: {
setName: function(e){
this.$store.commit('setName', e.target.value);
}
}
});
const routes = [
{ path: '/', component: homeComponent }
];
const router = new VueRouter({
routes
});
new Vue({
router,
render: h => h('router-view')
}).$mount('#app');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment