Created
July 27, 2017 17:44
-
-
Save BrianRosamilia/d1785ea423cce4e48ffe8b63b3b614ba to your computer and use it in GitHub Desktop.
Semi Minimal Vue/Vuex/Vue-router boilerplate
This file contains hidden or 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
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