å æ¥ã®ãOpenIL vol.2ãã«ã¦ã5åã§ãããVue.jsãã¨ããLTãçºè¡¨ãã¾ããã
- ãã¹ã©ã¤ãæãã¤ã³ãã£ãããã«ã¼ãå ¬éåå¼·ä¼ãOpenIL vol.2ãéå¬ã¬ãã¼ããåç·¨
- ãã¹ã©ã¤ãæãã¤ã³ãã£ãããã«ã¼ãå ¬éåå¼·ä¼ãOpenIL vol.2ãéå¬ã¬ãã¼ããå¾ç·¨
ãã®è¨äºã¯ããã®æã®LTã®è³æãå
ã«ããã°åãããã®ã§ãã

jQueryã¯é å¼µãã°é å¼µãã»ã©è¾ããªã
jQueryãç°¡åã«åãã®ãããµã¤ããä½ãã¦ã¨ã¦ã便å©ã§ãããã
// ä½ãç»é¢ã«åæ ãã
$(".hoge").html("夿´ãããå
容");
// 夿´æã«ä½ãå¦çãã¦å¤æ´ãã
$(".foo").on("change", function() {
$(".bar").html("夿´ãããå
容");
});
ã¤ãã³ããåãåã£ã¦ãè²ã
ã¨å¦çããã¦ãDOMæä½çã§ç»é¢ã«åæ ãããã¨ã¦ã便å©ã§ãã
ãã ãjQueryã§é å¼µãããã¨é端ã«è¾ããªã£ã¦ãã¾ãã
åç´ãªç»é¢æä½ãªãã¨ããããè¤éãªDOMæä½ããã¦ããã¨ãããHTMLã®æ§é ãå¤ãããã¨ããã表示å
容ãå¤ãããã¨ãã«ã人éã¯æ»ãã§ãã¾ãã¾ãã
ä¾ãã°ãã³ãã¬ã¼ãã使ã
æ»ã«ãããªãã®ã§ãä¾ãã°mustacheã_.template()ã®ãããªãã³ãã¬ã¼ãã使ãã¾ãã
ä¾ãã°mustacheã®ãã³ãã¬ã¼ãä¾ã§ãã
<script type="text/template">
<div class="box">
<h1>{{title}}</h1>
<ul>
{{#items}}
<li>{{.}}</li>
{{/items}}
</ul>
</div>
</script>
ãããªæãã«HTMLãç¨æãã¦ããã«JSã®å¤æ°ãæµãè¾¼ãã¨ããæ¹æ³ãã¨ããã¨ã§å¤§åç·©åããã¾ãã
ããã¾ãããããã§ãç»é¢ãè¤éã«ãªãã¨ããã¼ã¿ã®é£æºåæãå¢ãã¦å¤§å¤ã«ãªã£ã¦ãã¾ãã¾ãã
çµå±ã®ã¨ãããã¤ãã³ããæ¤ç¥ãã¦ãããããã¦çµæãç»é¢ã«åæ ãããã¨ããå¦çãé »åºããã®ã¯é¿ããããªããããå¾ã
ã«é¢åã«ãªã£ã¦ãã¾ãã
ããããã©ããªãã°å¹¸ããã
ããã§ä½¿ãã®ããã¼ã¿ãã¤ã³ãã£ã³ã°ã§ãããä¾ãã°Vue.jsã®ãããªã©ã¤ãã©ãªã§ãã
ããVue.jsã使ãã
- Knockout.jsã¨ãAngular.jsã«è¿ã
- é¡ä¼¼ã®ã©ã¤ãã©ãªã¨æ¯ã¹ã¦ãã·ã³ãã«ã§ä½¿ãããã
- ã¡ãã£ã¨ãããã¨ã«ä½¿ãã®ã«ãåãã¦ãã
- æ©è½ãç¹åãã¦ããããä»ã®ãã®ã¨çµã¿åãããããã
Vue.jsã®ãµã³ãã«
åºæ¬ã¯mustacheãã£ããã§ãã
<html>
<body>
<div>åå: {{firstName}}</div>
<div>èå: {{lastName}}</div>
<div>ãã«ãã¼ã : {{fullName}}</div>
<input type="text" v-model="firstName">
<input type="text" v-model="lastName">
</body>
</html>
vue = new Vue({
el: "body",
data: {
firstName: "shinnosuke",
lastName: "sato"
},
computed: {
fullName: function() {
return this.firstName + " " + this.lastName;
}
}
});
HTMLã«ç´æ¥mustache風ã®ã¿ã°ãåãè¾¼ã¿ãVueãªãã¸ã§ã¯ããä½ãã ãã
ä¸é¨ãé¤ãã¦ãã ã®mustacheã¨åãããã«è¦ãã¾ãããHTMLä¸ã«è¡¨ç¤ºããå¤ã¨JSå´ã®å¤ãå®å
¨ã«é£åãã¦ãã¾ãã

Vue.jsã¯ãObject.definePropertyãã使ã£ã¦ããããã£ã®å徿ã夿´æã®å¦çãå¤ãã¦ããããããã¼ã¿ã夿´ããã¨HTMLãæ¸ãå¤ããã¾ããããã¼ã¿ãåå¾ããã¨ãã©ã¼ã ã®å¤ãåå¾ã§ãã¾ãã
åç´ãªå¤æ°ã®è¡¨ç¤ºã¯{{hoge}}ã¨mustacheé¢¨ã«æ¸ãã ããããããè¤éãªãã¨ãããå ´åã¯ãã£ã¬ã¯ãã£ãã¨ããHTMLã®å±æ§ã¨ãã¦ãv-foo=”bar”ããæå®ããæ¹æ³ã使ãã¾ãã
ä¾ãã°ç¹°ãè¿ãå¦çã¯ãv-repeat=”items”ããã¤ãã³ãå¦çã¯ãv-on=”click: onClick();”ãã®ããã«ãã¾ãã
ãã®ä»ã®åºæ¥ããã¨
5åã§èª¬æããããªãããããVue.jsã«ã¯ä¾¿å©ãªæ©è½ãããã¾ãã
- ç¬èªã®HTMLã¿ã°ã®ãããªãã®ãä½ãã
- ç¬èªãã£ã¬ã¯ãã£ããå®ç¾©åºæ¥ã
- SVGã«ã対å¿ãã¦ããã®ã§ã¤ã³ã¿ã©ã¯ãã£ããªå³å½¢ãä½ãã
以åãã·ããæç»ããã®ãæµè¡ãã¾ããããããããµã³ãã«ã¨ãã¦Vue.jsã§ããããããã«ãã¦ã¿ã¾ããã

ãããªæãã®åãã®ãããã¼ã¸ãæ¬å½ã«ç°¡åã«ä½ããã®ã§ãVue.jsãå§ãã§ãã
é§ãè¶³æ°å³ã«ãªãã¾ããããVue.jsã®è¯ããå°ãã§ãä¼ããã°å¹¸ãã§ãã

