Vue.jså ¥éïŒåºæ¬ãšãªãæŠå¿µãç解ãã
Vue.jsãšã¯ïŒãã¬ãŒã ã¯ãŒã¯ã®å šäœå
Vue.jsã¯ãWebã€ã³ã¿ãŒãã§ãŒã¹ã®éçºã容æãã€å¹ççã«ããããã®ããã°ã¬ãã·ãJavaScriptãã¬ãŒã ã¯ãŒã¯ã§ããæè»æ§ã«å¯ã¿ãç°¡æœãªAPIãæã¡ãç¬èªã®æ¹åŒã§DOMãšããŒã¿ãçµã³ã€ããããšãå¯èœã§ãããã«ãã£ãŠåçãªWebã¢ããªã±ãŒã·ã§ã³ãæ§ç¯ã§ããŸããVue.jsã¯ããããªã¹ããªã³ã¢ãæã¡ã€ã€ãå¿ èŠã«å¿ããŠæ©èœãè¿œå ããŠããããšãã§ãããšã³ã·ã¹ãã ãæäŸããŸãã
Vue.jsã¯ä»ã®å€ãã®JavaScriptãã¬ãŒã ã¯ãŒã¯ãšã¯ç°ãªããåŸã ã«å°å ¥ããããšãå¯èœã§ããæ¢åã®ãããžã§ã¯ãã«äžéšã ãVue.jsãé©çšããããšã§ãåŸæ¥ã®éçºãããŒã厩ãããšãªãã段éçã«ã¢ããªã±ãŒã·ã§ã³å šäœãVue.jsããŒã¹ã«ç§»è¡ãããããšãå¯èœã§ãã
ãã®ãã¬ãŒã ã¯ãŒã¯ã¯é床ãšå¹çãæåªå ã«ããã¯ãã¹ãã©ãããã©ãŒã ã®ãµããŒããæäŸãããããã·ã³ã°ã«ããŒãžã¢ããªã±ãŒã·ã§ã³ããNativeã¢ããªã®éçºããã¹ã¯ãããã¢ããªã±ãŒã·ã§ã³ã«è³ããŸã§ãå¹ åºãã·ããªãªã§å©çšãããŠããŸãã
Vue.jsã®äž»ãªç¹åŸŽïŒãªã¢ã¯ãã£ãã·ã¹ãã ãšãã®å©ç¹
Vue.jsã®æãéç«ã£ãŠããç¹åŸŽã®äžã€ã¯ããªã¢ã¯ãã£ããªããŒã¿ãã€ã³ãã£ã³ã°ã§ãããªã¢ã¯ãã£ãã·ã¹ãã ã«ãããŠã¯ãããŒã¿ãå€æŽããããšããã®å€æŽãèªåçã«é¢é£ããDOMã«åæ ãããŸããããã«ãããæåã§DOMãæŽæ°ããç ©ãããããªããªããŸãã
ãã®ãªã¢ã¯ãã£ããªæ§è³ªã¯ãéçºè ãããŒã¿ç®¡çãç¶æ ã®åæã«é¢ããŠå¿é ããããšãªããã¢ããªã±ãŒã·ã§ã³ã®ããžãã¯ã«éäžã§ããããã«ããŸããéçºãããŒãã¹ã ãŒãºã«ãªãããã°ã®å¯èœæ§ãæžå°ããŸãããŸããVue.jsã®ãªã¢ã¯ãã£ãã·ã¹ãã ã¯ãå¹ççãªå€æŽæ€åºãšæé©åãããããŒãã£ã«DOMã¢ã«ãŽãªãºã ã«ããé«éãªã¬ã³ããªã³ã°ãå®çŸããŸãã
éçºè ã«ãšã£ãŠãããšã³ããŠãŒã¶ãŒã«ãšã£ãŠãå¿«é©ãªäœéšãæäŸãããã®ç¹åŸŽã¯ãVue.jsã®äººæ°ãæ¯ããæ žãšãªã£ãŠããŸãã
Vue.jsã®ã³ã¢ã³ã³ã»ããïŒã³ã³ããŒãã³ãããŒã¹ã®ã¢ãŒããã¯ãã£
Vue.jsã®ã³ã¢ãšãªãã³ã³ã»ããã®äžã€ã«ãã³ã³ããŒãã³ãããŒã¹ã®ã¢ãŒããã¯ãã£ããããŸããããã¯ã倧ããªã¢ããªã±ãŒã·ã§ã³ãå°ããªãåå©çšå¯èœãªã³ã³ããŒãã³ãã«åå²ããèšèšææ³ã§ããåã³ã³ããŒãã³ãã¯ç¬ç«ããŠããããããããç¬èªã®ããŒã¿ãšã¡ãœãããæã¡ãç¹å®ã®æ©èœãå®çŸããŸãã
ãã®ã¢ãããŒãã«ãããã³ãŒãã®åå©çšæ§ãšä¿å®æ§ãåäžãã倧èŠæš¡ãªã¢ããªã±ãŒã·ã§ã³éçºããã管çãããããªããŸãããŸããã³ã³ããŒãã³ãã¯éå±€çã«é 眮ããã芪åé¢ä¿ã圢æããªããããŒã¿ãšã€ãã³ããããåãããããšãã§ããŸãã
Vue.jsã«ãããŠã³ã³ããŒãã³ãã¯ãã¡ãŒã¹ãã¯ã©ã¹ã®åžæ°ãšãããŠããããã¬ãŒã ã¯ãŒã¯ã¯ã³ã³ããŒãã³ãã®å®çŸ©ããã©ã€ããµã€ã¯ã«ã®ç®¡çãã¹ã¿ã€ãªã³ã°ãŸã§å šãæ°ããã¬ãã«ã®çŽ°ããªæäœæ§ãéçºè ã«æäŸããŸãã
Vue.jsã®çãç«ã¡ãšéçºã³ãã¥ããã£ã®çŸç¶
Vue.jsã¯ããšãŽã¡ã³ã»ãŠãŒã«ãã£ãŠèšç«ããã圌ãGoogleã§AngularJSãããžã§ã¯ãã«åãçµãã§ããçµéšãããããç°¡æœã§æè»ãªãã¬ãŒã ã¯ãŒã¯ãåæããŠããããšããã£ããã§çãŸããŸãããæåã®ãªãªãŒã¹ã¯2014幎ã«ç»å Žãããã®äœ¿ããããããç¬ãéã«æ³šç®ãéããŸããã
æ¥ãè¿œãããšã«Vue.jsã¯æé·ããçŸåšã§ã¯äžçäžã«å¹ åºãéçºè ã³ãã¥ããã£ãååšããŸããéçºè ãã¡ãèªç±ã«ç¥èãå ±æããããŸããŸãªãã©ã°ã€ã³ãããŒã«ãäœæããŠãã¬ãŒã ã¯ãŒã¯ã匷åããŠããäžæ¹ã§ãæ žãšãªãVue.jsããŒã ãããã¬ãŒã ã¯ãŒã¯ãåžžã«ææ°ã®ãŠã§ãéçºã®æœ®æµã«åãããŠæŽæ°ãç¶ããŠããŸãã
é«å質ãªããã¥ã¡ã³ããŒã·ã§ã³ãšã芪åã§ãµããŒããå å®ããã³ãã¥ããã£ã®ãããã§ãVue.jsã¯ååŠè ã§ãç¿åŸãããããã¬ãŒã ã¯ãŒã¯ãšããŠç¥ãããŠããŸããããã«ãããVue.jsã¯ä»åŸãå€ãã®ãããžã§ã¯ãã§éžã°ãããã¬ãŒã ã¯ãŒã¯ã§ããããšãæåŸ ãããŠããŸãã
Vue.jsã®ã»ããã¢ããïŒéçºç°å¢ã®æ§ç¯
Vue.jsã¯ã¢ãã³ãªWebéçºã«äžå¯æ¬ ãªãã¬ãŒã ã¯ãŒã¯ã®äžã€ãšãªããéçºç°å¢ã®æ§ç¯ã¯ãããžã§ã¯ãæåã®éµãæ¡ããŸããæ£ããèšå®ãšããŒã«ã®éžæã«ãããéçºã®å¹çæ§ãšããã©ãŒãã³ã¹ã倧ããåäžããŸããããã§ã¯Vue.jsãå§ããããã«å¿ èŠãªã»ããã¢ããããã»ã¹ã解説ããŸãã
åããŠVue.jsãå©çšããéçºè ãžã®æåŒããšããŠãéçºç°å¢ã®ç¢ºç«ããåºæ¬çãªãããžã§ã¯ãã®éå§æ¹æ³ãŸã§ãäžå¯§ã«èª¬æããŸãããã¬ãŒã ã¯ãŒã¯ã«æ £ããŠããªãæ¹ã§ãã¹ã ãŒãºã«åãçµããããã段éçãªã¬ã€ããæäŸããŸãã
çŸä»£çãªWebã¢ããªã±ãŒã·ã§ã³ãéçºããéã®æè»æ§ãšæ¡åŒµæ§ãæäŸããVue.jsã¯ãéçºè ã®éã§é«ã人æ°ãæç¶ããŠããŸãããã®ã»ã¯ã·ã§ã³ã§ã¯Vue.jsã®éçºç°å¢ãã»ããã¢ããããåæ©çãªã¹ããããèŠãŠãããŸãããã
Vue.jséçºã®ããã®ããŒã«ã»ãšãã£ã¿éžã³
Vue.jsã掻çšããäžã§æåã®ã¹ãããã¯ãé©åãªã³ãŒããšãã£ã¿ãIDEã®éžæã§ããVisual Studio CodeãWebStormãªã©ãå€ãã®åªããéžæè¢ããããŸãããããã¯Vue.jsã®ã³ã³ããŒãã³ãããã£ã¬ã¯ãã£ãã®ã·ã³ã¿ãã¯ã¹ãã€ã©ã€ãããµããŒãããŠãããéçºäœéšãæ Œæ®µã«åäžãããŸãã
ãããã®ããŒã«ã¯ãã©ã°ã€ã³ãæ¡åŒµæ©èœã«ãã£ãŠããã«æ©èœãæ¡åŒµããããšãã§ããŸããããšãã°ãVeturãVue.js Extension Packã¯Visual Studio Codeã§Vue.jsãå¿«é©ã«å©çšããããã«éå®ããŸãããããã®ã¢ããªã³ã¯è£å®ãã¹ããããã®æäŸãéããŠãã³ãŒãã£ã³ã°é床ã®åäžã«å¯äžããŸãã
ãããããšãã£ã¿éžã³ã¯å人ã®å¥œã¿ããããžã§ã¯ãã®èŠä»¶ã«ãäŸåããŸããéèŠãªã®ã¯ãVue.jséçºãæ¯æŽããŠå¹çãåäžãããæ©èœãè±å¯ã§ããããšã§ããèªåã®éçºã¹ã¿ã€ã«ã«åã£ããšãã£ã¿ãéžã³ãŸãããã
Vue CLIã®å©çšïŒVueãããžã§ã¯ãã®çæãšèšå®
Vue CLIã¯ãVue.jsã§ã®ãããžã§ã¯ãäœæãšèšå®ãç°¡åã«ãã匷åãªã³ãã³ãã©ã€ã³ããŒã«ã§ããæ°è¡ã®ã³ãã³ãã§æ°ãããããžã§ã¯ãã®éªšçµã¿ãäœããå¿ èŠãªäŸåé¢ä¿ãèªåçã«èšå®ããŠãããŸãã
Vue CLIã䜿çšããã«ã¯ããŸãNode.jsãšnpmãã€ã³ã¹ããŒã«ãããŠããå¿ èŠããããŸããããããæºåã§ããäžã§ã`npm install -g @vue/cli`ã³ãã³ãã䜿ã£ãŠVue CLIãã€ã³ã¹ããŒã«ããŸããã€ã³ã¹ããŒã«åŸã«ã¯ã`vue create project-name`ãå®è¡ããããžã§ã¯ããã©ã«ããçæããŸãããã
Vue CLIã¯ããŸããŸãªããªã»ãããèšå®ãæäŸããéçºè ãæäœæ¥ã§èšå®ããæéãçããŸããLintingããŒã«ããŠããããã¹ããE2Eãã¹ããªã©ã®å°å ¥ãç°¡åã«ããŠãéçºããã»ã¹ãåçåããŸãã
ãããžã§ã¯ãæ§é ã®è§£èª¬ïŒVueãã¡ã€ã«ã®æ§æèŠçŽ
Vue.jsãããžã§ã¯ããäœæãããšãç¹å®ã®ãã£ã¬ã¯ããªæ§é ã®äžã«å€æ°ã®ãã¡ã€ã«ãšãã©ã«ããçæãããŸãããã®äžæ žãšãªãã®ãã`.vue`ãã¡ã€ã«ãã€ãŸãåäžãã¡ã€ã«ã³ã³ããŒãã³ãã§ãããããã®ãã¡ã€ã«ã¯ãã³ãã¬ãŒããã¹ã¯ãªãããã¹ã¿ã€ã«ãäžã€ã«ãŸãšããã³ã³ããŒãã³ãããŒã¹ã®éçºãä¿ããŸãã
`.vue`ãã¡ã€ã«å ã«ã¯ ``ã `