w "OFXT"TUSBUFHZ"TBMFTͱ͍ͬͨෳͷϓϩμΫτΛఏڙ w ౦༸ܦࡁ͍͢͝ϕϯνϟʔ࠷৽൛ w "TUSBUFHZ w Σϒχϡʔε͔ΒࣗવݴޠॲཧͰࢢτϨϯυاۀಈ Λநग़͠ɺߏԽɾՄࢹԽ͢Δ͜ͱͰϏδωεͷҙࢥܾఆΛ αϙʔτ w ٕज़తͳશମߏʹ͍ͭͯฐࣾςοΫϒϩάͷهࣄΛ͝ཡ ͍ͩ͘͞ "TUSBUFHZ 3
Ұޱʹੑೳͱݴͬͯ৭ʑ͋Δ͕ɺେ͖͍σʔλΛऔΓ ճͯ͠ΠϯλϥΫςΟϒͳίϯςϯπΛ࡞Δͱ͍͏͜ͱ Ͱɺࠓճ͍ΘΏΔϥΠϯλΠϜੑೳͷ w ʮਪଌ͢ΔͳɺܭଌͤΑʯͷమଇʹैͬͯɺ$ISPNF %FW5PPMTͰϓϩϑΝΠϦϯάͯ͠ϘτϧωοΫΛݟͭ ͚Δˠվળ͢Δͷ܁Γฦ͠ w %FW5PPMTͷ͍ํࣗମެࣜυΩϡϝϯτͳͲΛ ࢀর͍͚ͨͩΕ Ҏ߱ͷܭଌɺҎԼͷڥͰ࣮ࢪ w .BD#PPL1SP Πϯν w ()[ίΞ*OUFM$PSFJ w ϝϞϦ(# w NBD04 w 7VF 5
7VF͚ʹ͍͔ͭ͘ϥΠϒϥϦ͕͋ΔͷͰదʹબఆ͢Δͱྑ͍ w IUUQTHJUIVCDPN"LSZVNWVFWJSUVBMTDSPMMFS w ˢαϯϓϧͰͪ͜ΒΛར༻ w IUUQTHJUIVCDPNUBOHCDWVFWJSUVBMTDSPMMMJTU w "TUSBUFHZͰɺҰ෦ͷը໘͕ෳࡶʹͳ͍ͬͯΔՕॴطଘϥΠϒϥϦ͕͑ͳ͔ͬͨͷͰɺ *OUFSTFDUJPO0CTFSWFSΛͬͯࣅͨΑ͏ͳΈΛࣗ࡞͍ͯ͠Δ 8
ͷ0QUJPO"1* ͩͱͦ͜Λ੍ޚ͢Δज़͕ͳ͍ʜʁ w ࣮ɺJT'SP[FOͳΦϒδΣΫτ3FBDUJWFม͞Εͳ͍ʂ w ֘ՕॴIUUQTHJUIVCDPNWVFKTWVFCMPCGGEGDCFCF TSDDPSFPCTFSWFSUSBWFSTFKT-- w ࢀߟهࣄIUUQTSFTJEFJDHJUIVCJPCMPHIBOEMJOHMPOHBSSBZTQFSGPSNBOUMZJOWVFKT w ͭ·ΓɺόοΫΤϯυ͔ΒಘΒΕͨσʔλ0CKFDUGSFF[F ͓ͯ͘͠ͱྑ͍ const data = await fetch(...); // όοΫΤϯυ͔ΒσʔλΛऔಘͯ͠… this.data = Object.freeze(data); // freezeͯ͠Vueͷίϯϙʔωϯτʹ͚ͩ͢ 12
w ͜͜·Ͱ0QUJPO"1*Ͱͷͩͬͨ w $PNQPTJUJPO"1*Ͱɺ3FBDUJWFͷมࣗಈతʹͰͳ͘໌ࣔతʹߦ͏ඞཁ͕͋ΓɺͦͷͨΊͷ"1*ͷதʹ TIBMMPX3FBDUJWFTIBMMPX3FGͱ͍͏࠶ؼతʹ3FBDUJWFʹม͠ͳ͍ͷ͋Δ w ެࣜυΩϡϝϯτͰ4LJQQJOHQSPYZDPOWFSTJPODBOQSPWJEFQFSGPSNBODFJNQSPWFNFOUTXIFO SFOEFSJOHMBSHFMJTUTXJUIJNNVUBCMFEBUBTPVSDFTΈ͍ͨͳهड़͕͋Δ w ͢ͳΘͪɺ0QUJPO"1*Ͱ0CKFDUGSFF[F ͨ͠ͱ͖ͱಉͷޮՌ͕ಘΒΕΔ // const data = ref([]); //Α͋͘Δఆٛํ๏ const data = shallowRef([]); // shallowRefͰσʔλΛఆٛ data.value = await fetch(...); // ͜͜Ͱ࠶ؼతʹreactiveʹͳΒͳ͍ 14
ྻͷ݁߹ɺBSSBZDPODBU BSSBZ ΑΓBSSBZQVTI BSSBZ ͷํ͕ૣ͍ w ࢀߟهࣄIUUQTEFWUPVJMJDJPVTKBWBTDSJQUBSSBZQVTIJTYGBTUFSUIBOBSSBZDPODBUPLJ w ޙऀഁյతมߋͳͷͰݫີʹಉ͡ڍಈͰͳ͍ͷҙ w େ͖͍σʔλશମͷྻʹͳ͍ͬͯΔϓϩύςΟΛूΊͯ͘ΔɺΈ͍ͨͳूܭॲཧΛॻ͘ͱ͖ʹؾʹֻ ͚͓ͯ͘ͱྑ͍ w "TUSBUFHZͰ͜Ε͕ΊͬͪΌޮ͘໘͕͋Γ·ͨ͠ w ྻͷϢχʔΫॲཧ"SSBZGSPN OFX4FU BSSBZ Λ͏ͱ؆୯ૣ͍ w ࢀߟهࣄIUUQTRJJUBDPNQJSPPSJUFNTDGGCGB 16