Slide 1

Slide 1 text

Vue × Vuex ͷΞʔΩς Ϋνϟ׬શʹཧղͨ͠

Slide 2

Slide 2 text

ࣗݾ঺հ • ԕ౻୓໻ (entaku) • Twitter: @entaku19890818 • iOS/Android/Vue ΤϯδχΞ • ܦྺ: ͳΜͪΌͬͯSE
 ->NWΤϯδχΞ[SIer]
 ->αʔόʔαΠυΤϯδχΞ[SIer](java/PHP..etc)
 ->iOS/Android ΞϓϦ։ൃ[ελʔτΞοϓ]
 Vue/Android…etc@CBCloudʹͳΓ·͢ <- NEW

Slide 3

Slide 3 text

ʢࢀরɿhttps://cb-cloud.com/ ʣ

Slide 4

Slide 4 text

ΞδΣϯμ • 0. ར༻ٕज़ • 1. Vue / Vuex ΞʔΩςΫνϟɹʙԿΛͲ͜ʹدͤΔ͔ʁʙ • 2. σβΠϯ ʙσβΠφʔͱͷίϛϡχέʔγϣϯͱίϯϙʔ ωϯτͷ෼͚ํʁʙ • 3. ։ൃݴޠ ʙTypeScriptΛ࢖͍͍ͨʙ

Slide 5

Slide 5 text

0.ར༻ٕज़

Slide 6

Slide 6 text

0.ར༻ٕज़

Slide 7

Slide 7 text

0.ར༻ٕज़ • Vue (ൃԻ͸ / v j u ː / ɺ view ͱಉ༷ʣ͸ϢʔβʔΠϯλʔϑΣΠεΛߏங͢ΔͨΊͷϓϩ άϨογϒϑϨʔϜϫʔΫͰ͢ɻଞͷҰຕ൘(ϞϊϦγοΫ: monolithic)ͳϑϨʔϜϫʔΫ ͱ͸ҟͳΓɺVue ͸গͣͭ͠ద༻͍͚ͯ͠ΔΑ͏ʹઃܭ͞Ε͍ͯ·͢ɻத֩ͱͳΔϥΠϒϥ Ϧ͸ view ૚͚ͩʹয఺Λ౰͍ͯͯ·͢ɻͦͷͨΊɺ࢖͍࢝ΊΔͷ΋ɺଞͷϥΠϒϥϦ΍ط ଘͷϓϩδΣΫτʹ౷߹͢Δͷ΋ɺͱͯ΋؆୯Ͱ͢ɻ·ͨɺϞμϯͳπʔϧ΍αϙʔτϥΠ ϒϥϦͱซ༻͢Δ͜ͱͰɺચ࿅͞ΕͨγϯάϧϖʔδΞϓϦέʔγϣϯͷ։ൃ΋ՄೳͰ͢ɻ ʢࢀরɿhttps://jp.vuejs.org/ ʣ

Slide 8

Slide 8 text

0.ར༻ٕज़ • Nuxt͸ɺϞμϯͳ web ΞϓϦέʔγϣϯΛ࡞੒͢Δ Vue.js ʹج͍ͮͨϓϩά ϨογϒϑϨʔϜϫʔΫͰ͢ɻVue.js ެࣜϥΠϒϥϦʢvueɺvue-router ΍ vuexʣ͓Αͼڧྗͳ։ൃπʔϧʢwebpackɺBabel ΍ PostCSSʣʹج͍ͮͯ ͍·͢ɻ Nuxt ͷ໨ඪ͸ɺ༏Εͨ։ൃऀΤΫεϖϦΤϯεΛ೦಄ʹஔ͖ɺWeb ։ൃΛڧྗ͔ͭߴੑೳʹ͢Δ͜ͱͰ͢ɻ ʢࢀরɿhttps://ja.nuxtjs.org/ ʣ

Slide 9

Slide 9 text

0.ར༻ٕज़ • ElementUI͸ɺVue 2.0ϕʔεͷUIίϯϙʔωϯτϥΠϒϥϦɻ • ͋Β͔͡ΊElementUIͰ༻ҙ͞ΕͨίϯϙʔωϯτΛ༨෼ʹ HTML/CSS/JSΛΧελϜ͢Δඞཁ͕ͳ͘ͳΔ ʢࢀরɿhttps://element.eleme.io/ ʣ

Slide 10

Slide 10 text

جຊߏ੒ /utils /store /static /plugins /pages ./package.json ./nuxt.config.js /middleware /lib_sources /layouts /components /organisms /molecules /atomsɹ /assets /api

Slide 11

Slide 11 text

Nuxt ॳظߏ੒ BTTFUTσΟϨΫτϦʹ͸4UZMVT΍4"44ɺ*NBHFɺ'POUͷΑ͏ͳί ϯύΠϧ͞Ε͍ͯͳ͍ϑΝΠϧΛೖΕ·͢ɻ DPNQPOFOUTσΟϨΫτϦʹ͸7VFKTͷίϯϙʔωϯτϑΝΠϧΛೖ Ε·͢ɻ͜ΕΒͷίϯϙʔωϯτͰ͸BTZOD%BUB΍GFUDIΛ࢖͏͜ͱ ͸Ͱ͖·ͤΜɻ MBZPVUTσΟϨΫτϦ͸ΞϓϦέʔγϣϯͷϨΠΞ΢τΛؚΈ·͢ɻϨ ΠΞ΢τ͸ϖʔδͷ֎؍Λมߋ͢ΔͨΊʹ࢖༻͞Ε·͢ʢྫ͑͹αΠυ όʔͳͲʣɻ NJEEMFXBSFσΟϨΫτϦʹ͸ΞϓϦέʔγϣϯͷϛυϧ΢ΣΞΛೖΕ ·͢ɻϛυϧ΢ΣΞΛ࢖ͬͯɺϖʔδ΍ϖʔδάϧʔϓʢϨΠΞ΢τʣΛ ϨϯμϦϯά͢ΔΑΓ΋લʹ࣮ߦ͞ΕΔΧελϜؔ਺ΛఆٛͰ͖·͢ɻ QBHFTσΟϨΫτϦʹ͸ΞϓϦέʔγϣϯͷϏϡʔٴͼϧʔςΟϯάϑΝ ΠϧΛೖΕ·͢ɻ/VYUKTϑϨʔϜϫʔΫ͸͜ͷσΟϨΫτϦ಺ͷ͢΂ͯ ͷWVFϑΝΠϧΛಡΈࠐΈɺΞϓϦέʔγϣϯͷϧʔλʔΛ࡞੒͠· TUBUJDσΟϨΫτϦ͸௚઀αʔόͷϧʔτʹ഑ஔ͞ΕʢTUBUJD SPCPUTUYU͸IUUQMPDBMIPTUSPCPUTUYUͰΞΫηεՄೳͰ ͢ʣɺมߋ͞Εͳ͍Մೳੑͷߴ͍ϑΝΠϧؚ͕·Ε͍ͯ·͢ʢྫ͑͹ɺ TUPSFσΟϨΫτϦʹ͸7VFYετΞͷϑΝΠϧΛೖΕ·͢ɻ7VFYε τΞ͸/VYUKTʹ෇ଐ͍ͯ͠·͕͢ɺσϑΥϧτͰ͸ແޮʹͳ͍ͬͯ· ͢ɻ͜ͷσΟϨΫτϦʹJOEFYKTɹϑΝΠϧΛ࡞੒͢ΔͱετΞ͕༗ޮ /utils /store /static /plugins /pages ./package.json ./nuxt.config.js /middleware /lib_sources /layouts /components /organisms /molecules /atomsɹ /assets /api ʢࢀরɿhttps://ja.nuxtjs.org/guide/directory-structure ʣ

Slide 12

Slide 12 text

Nuxt ॳظߏ੒ BTTFUTσΟϨΫτϦʹ͸4UZMVT΍4"44ɺ*NBHFɺ'POUͷΑ͏ͳί ϯύΠϧ͞Ε͍ͯͳ͍ϑΝΠϧΛೖΕ·͢ɻ DPNQPOFOUTσΟϨΫτϦʹ͸7VFKTͷίϯϙʔωϯτϑΝΠϧΛೖ Ε·͢ɻ͜ΕΒͷίϯϙʔωϯτͰ͸BTZOD%BUB΍GFUDIΛ࢖͏͜ͱ ͸Ͱ͖·ͤΜɻ MBZPVUTσΟϨΫτϦ͸ΞϓϦέʔγϣϯͷϨΠΞ΢τΛؚΈ·͢ɻϨ ΠΞ΢τ͸ϖʔδͷ֎؍Λมߋ͢ΔͨΊʹ࢖༻͞Ε·͢ʢྫ͑͹αΠυ όʔͳͲʣɻ NJEEMFXBSFσΟϨΫτϦʹ͸ΞϓϦέʔγϣϯͷϛυϧ΢ΣΞΛೖΕ ·͢ɻϛυϧ΢ΣΞΛ࢖ͬͯɺϖʔδ΍ϖʔδάϧʔϓʢϨΠΞ΢τʣΛ ϨϯμϦϯά͢ΔΑΓ΋લʹ࣮ߦ͞ΕΔΧελϜؔ਺ΛఆٛͰ͖·͢ɻ QBHFTσΟϨΫτϦʹ͸ΞϓϦέʔγϣϯͷϏϡʔٴͼϧʔςΟϯάϑΝ ΠϧΛೖΕ·͢ɻ/VYUKTϑϨʔϜϫʔΫ͸͜ͷσΟϨΫτϦ಺ͷ͢΂ͯ ͷWVFϑΝΠϧΛಡΈࠐΈɺΞϓϦέʔγϣϯͷϧʔλʔΛ࡞੒͠· TUBUJDσΟϨΫτϦ͸௚઀αʔόͷϧʔτʹ഑ஔ͞ΕʢTUBUJD SPCPUTUYU͸IUUQMPDBMIPTUSPCPUTUYUͰΞΫηεՄೳͰ ͢ʣɺมߋ͞Εͳ͍Մೳੑͷߴ͍ϑΝΠϧؚ͕·Ε͍ͯ·͢ʢྫ͑͹ɺ TUPSFσΟϨΫτϦʹ͸7VFYετΞͷϑΝΠϧΛೖΕ·͢ɻ7VFYε τΞ͸/VYUKTʹ෇ଐ͍ͯ͠·͕͢ɺσϑΥϧτͰ͸ແޮʹͳ͍ͬͯ· ͢ɻ͜ͷσΟϨΫτϦʹJOEFYKTɹϑΝΠϧΛ࡞੒͢ΔͱετΞ͕༗ޮ /utils /store /static /plugins /pages ./package.json ./nuxt.config.js /middleware /lib_sources /layouts /components /organisms /molecules /atomsɹ /assets /api /VYUͰ͍͍ͩͨἧ͏ʂʂ

Slide 13

Slide 13 text

ࠓճ଍ͨ͠΋ͷ BYJPTΛར༻ͨ͠"1*ͷॲཧ "UPNJD%FTJHOΛجʹͨ͠ίϯϙʔωϯτߏ੒ɻ 1BHFT͔Β͜ΕΒΛݺͼग़͢Α͏ʹͨ͠ ֎෦ϥΠϒϥϦͷಋೖʹ࢖༻ͨ͠ ڞ௨Ͱར༻͢Δؔ਺ͷอ؅ઌ /utils /store /static /plugins /pages ./package.json ./nuxt.config.js /middleware /lib_sources /layouts /components /organisms /molecules /atomsɹ /assets /api

Slide 14

Slide 14 text

ࠓճओʹ࿩͢ൣғ QBHFTσΟϨΫτϦʹ͸ΞϓϦέʔγϣϯͷϏϡʔٴͼϧʔςΟϯάϑΝ ΠϧΛೖΕ·͢ɻ/VYUKTϑϨʔϜϫʔΫ͸͜ͷσΟϨΫτϦ಺ͷ͢΂ͯ ͷWVFϑΝΠϧΛಡΈࠐΈɺΞϓϦέʔγϣϯͷϧʔλʔΛ࡞੒͠· TUPSFσΟϨΫτϦʹ͸7VFYετΞͷϑΝΠϧΛೖΕ·͢ɻ7VFYε τΞ͸/VYUKTʹ෇ଐ͍ͯ͠·͕͢ɺσϑΥϧτͰ͸ແޮʹͳ͍ͬͯ· ͢ɻ͜ͷσΟϨΫτϦʹJOEFYKTɹϑΝΠϧΛ࡞੒͢ΔͱετΞ͕༗ޮ /utils /store /static /plugins /pages ./package.json ./nuxt.config.js /middleware /lib_sources /layouts /components /organisms /molecules /atomsɹ /assets /api DPNQPOFOUTσΟϨΫτϦʹ͸7VFKTͷίϯϙʔωϯτϑΝΠϧΛೖ Ε·͢ɻ͜ΕΒͷίϯϙʔωϯτͰ͸BTZOD%BUB΍GFUDIΛ࢖͏͜ͱ ͸Ͱ͖·ͤΜɻ "UPNJD%FTJHOΛجʹͨ͠ίϯϙʔωϯτߏ੒ɻ 1BHFT͔Β͜ΕΒΛݺͼग़͢Α͏ʹͨ͠

Slide 15

Slide 15 text

1.Vue / Vuex ΞʔΩςΫ νϟɹʙԿΛͲ͜ʹدͤΔ͔ʁʙ

Slide 16

Slide 16 text

ࠓճओʹ࿩͢ൣғΠϝʔδ ʢࢀরɿhttps://vuex.vuejs.org/ja/ ʣ

Slide 17

Slide 17 text

Πϝʔδ͕ ׬શ͡Όͳ͍ؾ͕͢Δ ʢࢀরɿhttps://vuex.vuejs.org/ja/ ʣ

Slide 18

Slide 18 text

(FUUFS 1BHFT $POQP SOFOU ࠓճओʹ࿩͢ൣғͷΠϝʔδ(վม) ʢࢀরɿhttps://vuex.vuejs.org/ja/ ʣ

Slide 19

Slide 19 text

(FUUFS 1BHFT $POQP SOFOU Pages ʢࢀরɿhttps://vuex.vuejs.org/ja/ ʣ

Slide 20

Slide 20 text

Pages // HTMLΛॻ͘৔ॴ // JSΛॻ͘৔ॴ // CSSΛॻ͘৔ॴ

Slide 21

Slide 21 text

import Components from ‘@/components/organisms/Components' components: { Components } Pages - ίϯϙʔωϯτͷݺͼग़͠-

Slide 22

Slide 22 text

Pages - ίϯϙʔωϯτͷݺͼग़͠- import Components from `@/components/organisms/Components` components: { Components } ݺͼग़͠ 7JFX΁ͷඳը

Slide 23

Slide 23 text

Pages - vuexͷݺͼग़͠- import { mapGetters, mapActions} from 'vuex' computed: { ...mapGetters(`Store`, [‘data’]) }, async fetch({ store, params }) { store.dispatch(‘Store/getFirstData') }, methods: { ...mapActions(`Store`, [‘update’]), async getDriverOnMap() { await this.update() } }

Slide 24

Slide 24 text

Pages - vuexͷݺͼग़͠- import { mapGetters, mapActions} from 'vuex' computed: { ...mapGetters(`Store`, [‘data’]) }, async fetch({ store, params }) { store.dispatch(‘Store/getFirstData') }, methods: { ...mapActions(`Store`, [‘update’]), async getDriverOnMap() { await this.update() } } (FUUFSͰݺͼग़͠ ͨ಺༰ͷදࣔ (FUUFSͷݺͼग़͠ "DUJPOͷݺͼग़͠ "DUJPOͷ࣮ߦ ॳظදࣔͳͲ ͷݺͼग़͠

Slide 25

Slide 25 text

(FUUFS 1BHFT $POQP SOFOU Vuex ʢࢀরɿhttps://vuex.vuejs.org/ja/ ʣ

Slide 26

Slide 26 text

Vuex - state- export const state = () => ({ array: [], firstName: ``, lastName: ``, }) • σʔλͷอ؅ઌ

Slide 27

Slide 27 text

Vuex - mutations - export const mutations = { [types.SET_ARRAY](state, array) { state.array = array }, [types.SET_FIRST_NAME](state, firstName) { state.firstName = firstName }, [types.SET_LAST_NAME](state, lastName) { state.lastName = lastName } } • σʔλͷมߋ

Slide 28

Slide 28 text

export const getters = { fullName: state => { return state.firstName + state.lastName }, array: state => { return state.array } } Vuex - getters - • σʔλͷऔಘ

Slide 29

Slide 29 text

export const actions = { async fetchUser({ commit }) { const user = await fetchUser() commit(types.SET_FIRST_NAME, user.firstName) commit(types.SET_LAST_NAME, user.lastName) } } Vuex - actions - • σʔλͷߋ৽ॲཧ

Slide 30

Slide 30 text

ࣦഊͨ͜͠ͱ

Slide 31

Slide 31 text

ࣦഊͨ͜͠ͱ • StateΛ௚઀ࢀর͍ͯ͠Δ.. • ActionΛ௨͞ͳ͍MutationͷॲཧΛ͔͍ͯ͠·ͬͨ..

Slide 32

Slide 32 text

{{firstName}}
export default { computed: { ...mapState(`store`, ['firstName']) }, methods: { update() { this.$store.commit(‘store/' + types.SET_FIRST_NAME) } } } // CSSΛॻ͘৔ॴ ࣦഊͨ͜͠ͱ • StateΛ௚઀ࢀর͍ͯ͠Δ.. • ActionΛ௨͞ͳ͍MutationͷॲཧΛ͔͍ͯ͠·ͬͨ..

Slide 33

Slide 33 text

ͳͥState/MutationΛ௚઀ΑͿ ͷ͕·͍ͣͷ͔ʁ

Slide 34

Slide 34 text

ͳͥState/MutationΛ௚઀ΑͿ ͷ͕·͍ͣͷ͔ʁ • StateΛ௚઀ࢀর͢ΔͱɺVuexʹอଘ͞Ε͍ͯΔσʔλΛԿ΋հ ͣ͞ʹݟΔ͜ͱʹͳΔɻGetterͳͲͰදࣔ಺༰Λมߋͯ͠ࢀর ͍ͯ͠Δ৔߹͕͋ΔͨΊɺ৘ใͷҰҙੑ͕อͯͳ͘ͳΔ͔Β • MutationΛݺͿ͜ͱͰvueϑΝΠϧ͔ΒɺStateͷ಺༰Λ௚઀ॻ ͖׵͑Δ͜ͱ͕Ͱ͖Δɻ͜Ε͸ϩδοΫΛvueϑΝΠϧʹ಺ࡏ͠ ͯ͠·͏ͷͰɺߋ৽ॲཧ͸ActionsʹدͤΔɻ

Slide 35

Slide 35 text

(FUUFS 1BHFT $POQP SOFOU "

Slide 36

Slide 36 text

1.Vue / Vuex ΞʔΩςΫ νϟɹʙԿΛͲ͜ʹدͤΔ͔ʁʙ • ࢀরॲཧ͸gettersʹΑͤΔ • ߋ৽ॲཧ͸ActionsʹدͤΔ • vue͔Β͸gettersͱActionsͷΈΛࢀর͢Δ • state͸getters͔Βࢀর͢Δ • Mutation͸Actions͔Βߋ৽͢Δ

Slide 37

Slide 37 text

2.σβΠϯ ʙσβΠφʔͱͷίϛϡχ έʔγϣϯͱίϯϙʔωϯτͷ෼͚ํʁʙ

Slide 38

Slide 38 text

Atomic DesignΛ࠾༻ʂ

Slide 39

Slide 39 text

Atomic Designͱ͸ʁ • Atomic Design ͱ͸ ɺBrad Frostࢯ͕ఏএͨ͠UIઃܭʹ͓͍ͯ ίϯϙʔωϯτΛํ๏/ࢥ૝Ͱ͢ɻ • ϑϩϯτΤϯυͷઃܭࢥ૝ͷΑ͏ʹޠΒΕ͍ͯΔࣄ΋͋Γ·͢ ͕ɺ͋͘·ͰσβΠϯͷઃܭʹ͍ͭͯͷ΋ͷͰ͢ɻ ʢࢀরɿhttp://atomicdesign.bradfrost.com/ ʣ

Slide 40

Slide 40 text

Atomic Designͱ͸ʁ ʢࢀরɿhttp://atomicdesign.bradfrost.com/ ʣ

Slide 41

Slide 41 text

No content

Slide 42

Slide 42 text

Atoms props: { value: { type: String, default: '' } } // CSSΛॻ͘৔ॴ • element-uiίϯϙʔωϯτͷϥο ύʔ͔ͦͷ΋ͷΛ͍ΕΔ

Slide 43

Slide 43 text

Molecules
import Input from ‘@/components/atoms/Input’ import Label from ‘@/components/atoms/Label’ // CSSΛॻ͘৔ॴ • 1ͭҎ্ͷAtoms͕ར༻͞Ε͍ͯΔ

Slide 44

Slide 44 text

Organisms
import Form from ‘@/components/molecules/Form’ import Button from ‘@/components/molecules/Button’ export default { } // CSSΛॻ͘৔ॴ

Slide 45

Slide 45 text

Templates
import Basic from ‘@/components/organisms/Basic’ import Custom from ‘@/components/organisms/Custom’ // CSSΛॻ͘৔ॴ

Slide 46

Slide 46 text

Pages
import InputPage from ‘@/components/templates/InputPage’ // Store΁ͷΞΫηεॲཧ͸Pages͚ͩ…!

Slide 47

Slide 47 text

Atomic DesignͰࣦഊͨ͜͠ͱ

Slide 48

Slide 48 text

Atomic DesignͰࣦഊͨ͜͠ͱ • elementUI४ڌʹܾΊͨͷʹ͔ͳΓΧελϜͰ࡞ͬͯ͠·ͬͨ UIɻ • TemplatesΛೖΕͣʹ։ൃ͍ͯͨ͠… • ֊૚͕ਂ͘ͳΓແݶemit஍ࠈ..

Slide 49

Slide 49 text

ΧελϜͰ࡞ͬͯ͠·ͬͨUIɻ • ཁ݅ΛܾΊΔࡍʹσβΠϯ͕มΘͬͯ͠·͏ • σβΠϯγεςϜ͕ߏஙͰ͖͍ͯͳ͔ͬͨ

Slide 50

Slide 50 text

ʢࢀরɿhttps://note.mu/smartcamp_design/n/n4e4717e9d8d0 ʣ Atomic Design ͱ Figma ͷ૊Έ߹ΘͤͰσβΠϯ͕ศརʹͳΔʛσβΠϯγεςϜͷ࡞Γํ ΧελϜͰ࡞ͬͯ͠·ͬͨUIɻ

Slide 51

Slide 51 text

TemplatesΛೖΕͣʹ։ൃ͍ͯ͠ ͨ… ❌ ංେԽɹ

Slide 52

Slide 52 text

TemplatesΛೖΕͣʹ։ൃ͍ͯ͠ ͨ… ❌

Slide 53

Slide 53 text

ແݶemit஍ࠈ.. DMJDL&WFOU DMJDL&WFOU DMJDL&WFOU DMJDL&WFOU DMJDL&WFOU emit emit emit emit

Slide 54

Slide 54 text

3. ։ൃݴޠ ʙTypeScriptΛ࢖͍ͨ ͍ʙ (్த)

Slide 55

Slide 55 text

੩తܕ෇͚Ͱ։ൃ͍ͨ͠ʂʂʂʂ

Slide 56

Slide 56 text

ͦ͏SwiftͷΑ͏ʹ..

Slide 57

Slide 57 text

Swiftͷߏ଄ମͷѻ͍ struct Team: Decodable { let id:Int let name:String let shortName:String let crestUrl:URL let website:URL let venue:String } —— let team:Team = Team()

Slide 58

Slide 58 text

ͦ͜ͰTypeScriptͰ͢Α

Slide 59

Slide 59 text

Vuex - types - export interface RootState { version: string; } export interface TeamsState { teams: Team[] } export interface Team { ɹ id: number; name:string; area: Area; crestUrl: string; } export interface Area { id: string; name: string; } • σʔλͷఆٛ

Slide 60

Slide 60 text

Vuex - index/state- const state: TeamsState = { teams: [], }; export const todos: Module = { namespaced: true, state, getters, actions, mutations }; • σʔλͷอ؅ઌ

Slide 61

Slide 61 text

Vuex - mutations - export const mutations: MutationTree = { teamsLoaded(state, teams: Team[]) { state.teams = teams }, teamsError(state) { state.teams = [] } } • σʔλͷมߋ

Slide 62

Slide 62 text

const getters: GetterTree = { teams: (state: TeamsState) => { return state }, } Vuex - getters - • σʔλͷऔಘ

Slide 63

Slide 63 text

const actions: ActionTree= { fetch: async ({ commit }) => { try { const res = await axios.get('https://api.football-data.org/v2/competitions/PL/teams/', { headers: { 'X-Auth-Token': ‘XXXX' } }) const teams: Team[] = res.data.teams commit('teamsLoaded', teams) } catch (error) { // commit('teamsError') } }, }; Vuex - actions - • σʔλͷߋ৽ॲཧ

Slide 64

Slide 64 text

Pages - vuexͷݺͼग़͠-
{{ message }}
{{team.name}}
import { Vue } from 'vue-property-decorator'; import { mapGetters, mapActions, mapState, mapMutations } from 'vuex' export default Vue.extend({ data () { const message: string = 'This is a message' return { message } }, computed: { ...mapGetters(`Team`, ['teams']) }, async fetch ({ store, params }) { await store.dispatch('Team/fetch') } }) ·ͩͰ͖ͯͳ͍Α

Slide 65

Slide 65 text

GitHub https://github.com/entaku19890818/football-nuxt

Slide 66

Slide 66 text

·ͱΊ • ར༻ٕज़ • Nuxtʹ΄΅͢΂͕ͯ͋Δ • Vue / Vuex ΞʔΩςΫνϟ • ࢀরॲཧ͸gettersʹΑͤΔ • ߋ৽ॲཧ͸ActionsʹدͤΔ • σβΠϯ • UIϑϨʔϜϫʔΫΛҙࣝͨ͠σβΠφʔͱͷίϛϡχέʔγϣϯ • σβΠϯγεςϜͭ͘Δ • ։ൃݴޠ • TypeScriptͰ৺ཧత҆શੑͷߴ͍։ൃΛ…

Slide 67

Slide 67 text

͝੩ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠ʂ