Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Vuexについて

sinpey_g2
October 19, 2017

 Vuexについて

Vuexについて社内LTで発表したときの資料です

sinpey_g2

October 19, 2017
Tweet

Other Decks in Technology

Transcript

  1. Vue.jsͷͭΒ͍ͱ͜Ζ ਌ ࢠ ଙ isUpdated role index props : [

    role, isUpdated ] props : [ role ] props : [ role, index, isUpdated ] props : [ role, index, isUpdated ] props : [ isUpdated ] props : [ isUpdated ] ˡΤϥʔ
  2. Vuex ࢖͍ํ const store = new Vuex.Store({ state: { },

    mutations: { }, actions: { } }) // State // Mutation // Action
  3. state: { form: { article: { title: '', ogp_title: '',

    description: '', keywords: '', main_image: '', }, writers: [], blocks: [], status: Number, should_update: Boolean }, role: String, errors: [], }, Vuex ࢖͍ํ State
  4. mutations: { readRole (state, role) { state.role = role },

    }, this.$store.commit(‘readRole', ‘staff’) Vuex ࢖༻ྫ Mutation Mutarionͷએݴ ίϯϙʔωϯτͰMutationΛ࢖͏
  5. actions: { saveRole: function(context) { axios.post().then( context.commit(‘saveRole’)) } } methods:

    { saveRole() { this.$store.dispatch('saveRole') } } Vuex ࢖༻ྫ Action Actionͷએݴ ίϯϙʔωϯτ͔ΒActionͷ࣮ߦ