{"id":5939,"date":"2018-07-16T15:29:14","date_gmt":"2018-07-16T06:29:14","guid":{"rendered":"http:\/\/www.code-magagine.com\/?p=5939"},"modified":"2023-05-28T00:03:05","modified_gmt":"2023-05-27T15:03:05","slug":"%e3%80%90vue-js%e3%80%91%e3%80%8c%e3%82%b3%e3%83%b3%e3%83%9d%e3%83%bc%e3%83%8d%e3%83%b3%e3%83%88%e3%81%ae%e8%a6%aa%e5%ad%90%e9%96%a2%e4%bf%82%e3%80%8d%e3%81%ab%e3%81%a4%e3%81%84%e3%81%a6","status":"publish","type":"post","link":"http:\/\/www.code-magagine.com\/?p=5939","title":{"rendered":"\u3010Vue.js\u3011\u300c\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306e\u89aa\u5b50\u95a2\u4fc2\u300d\u306b\u3064\u3044\u3066"},"content":{"rendered":"<h2>\u300c\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306e\u89aa\u5b50\u95a2\u4fc2\u300d\u3068\u306f\uff1f<\/h2>\n<p>\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3067\u4ed6\u306e\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3092\u4f7f\u3046\u3053\u3068\u3092\u3001<span style=\"color: #ff0000;\"><strong>\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306e\u89aa\u5b50\u95a2\u4fc2<\/strong><\/span>\u3068\u547c\u3073\u307e\u3059\u3002<\/p>\n<p><strong><span style=\"color: #ff0000;\">Vue.js\u3067\u306f\u89aa\u304b\u3089\u5b50\u3078\u3057\u304b\u30c7\u30fc\u30bf\u3092\u53d7\u3051\u6e21\u3059\u3053\u3068\u304c\u3067\u304d\u307e\u305b\u3093\u3002\u5b50\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u304b\u3089\u89aa\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306e\u30c7\u30fc\u30bf\u3092\u53c2\u7167\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u305b\u3093\u3002<\/span><\/strong><\/p>\n<h2>\u4f8b<\/h2>\n<p>\u4f8b\u3048\u3070\u3001\u4e0b\u8a18\u306e\u3088\u3046\u306a\u30bd\u30fc\u30b9\u306b\u306a\u308a\u307e\u3059\u3002<span style=\"color: #ff0000;\"><strong>\u89aa\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306e\u4e2d\u3067\u3001\u5b50\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3092\u4f7f\u3063\u3066\u3044\u307e\u3059\u3002<\/strong><\/span><\/p>\n<p><span style=\"color: #ff0000;\"><strong>\u300ccomp-parent\u300d\u304c\u89aa\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3067\u3001\u300ccomp-child\u300d\u304c\u5b50\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8<\/strong><\/span>\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true\">&lt;!DOCTYPE html&gt;\r\n&lt;html lang=\"ja\"&gt;\r\n&lt;head&gt;\r\n&lt;meta charset=\"UTF-8\" \/&gt;\r\n&lt;title&gt;test&lt;\/title&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n&lt;div id=\"app\"&gt;\r\n&lt;comp-parent&gt;&lt;\/comp-parent&gt;\r\n&lt;\/div&gt;\r\n&lt;script src=\"https:\/\/cdn.jsdelivr.net\/npm\/vue@2.5.13\/dist\/vue.js\"&gt;&lt;\/script&gt;\r\n&lt;script&gt;\r\n\r\nVue.component('comp-parent', {\r\n  template: '&lt;div&gt;&lt;h1&gt;component\u306e\u89aa&lt;\/h1&gt;&lt;comp-child \/&gt;&lt;\/div&gt;'\r\n})\r\n\r\nVue.component('comp-child', {\r\n  template: '&lt;p&gt;component\u306e\u5b50&lt;\/p&gt;'\r\n})\r\n\r\nnew Vue({\r\n  el: '#app'\r\n})\r\n\r\n&lt;\/script&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;<\/pre>\n<h3>\u5b9f\u884c\u7d50\u679c<\/h3>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-5945\" src=\"http:\/\/www.code-magagine.com\/wp-content\/uploads\/2018\/07\/\u89aa\u5b50\u9593\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306e\u5b9f\u884c\u7d50\u679c.png\" alt=\"\" width=\"311\" height=\"150\" srcset=\"http:\/\/www.code-magagine.com\/wp-content\/uploads\/2018\/07\/\u89aa\u5b50\u9593\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306e\u5b9f\u884c\u7d50\u679c.png 311w, http:\/\/www.code-magagine.com\/wp-content\/uploads\/2018\/07\/\u89aa\u5b50\u9593\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306e\u5b9f\u884c\u7d50\u679c-300x145.png 300w\" sizes=\"(max-width: 311px) 100vw, 311px\" \/><\/p>\n<h2>\u89aa\u304b\u3089\u5b50\u3078\u306e\u30c7\u30fc\u30bf\u306e\u53d7\u3051\u6e21\u3057<\/h2>\n<p>\u901a\u5e38\u3001\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u9593\u3067\u306e\u901a\u4fe1\u306f\u3067\u304d\u306a\u3044\u3082\u306e\u3067\u3059\u304c\u3001<span style=\"color: #ff0000;\"><strong>props\u3092\u4f7f\u3048\u3070\u3001\u89aa\u306e\u5c5e\u6027\u306b\u6307\u5b9a\u3057\u305f\u5024\u3092\u3001\u5b50\u306b\u6e21\u3059<\/strong><\/span>\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<span style=\"color: #ff0000;\"><strong>\u6e21\u3059\u969b\u306f\u89aa\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306e\u5c5e\u6027\uff08v-bind\u7d4c\u7531\uff09\u3067\u6307\u5b9a<\/strong><\/span>\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true\">&lt;!DOCTYPE html&gt;\r\n&lt;html lang=\"ja\"&gt;\r\n&lt;head&gt;\r\n&lt;meta charset=\"UTF-8\" \/&gt;\r\n&lt;title&gt;test&lt;\/title&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n&lt;div id=\"app\"&gt;\r\n&lt;comp-parent&gt;&lt;\/comp-parent&gt;\r\n&lt;\/div&gt;\r\n&lt;script src=\"https:\/\/cdn.jsdelivr.net\/npm\/vue@2.5.13\/dist\/vue.js\"&gt;&lt;\/script&gt;\r\n&lt;script&gt;\r\n\r\nVue.component('comp-parent', {\r\n  template: '&lt;div&gt;&lt;h1&gt;component\u306e\u89aa&lt;\/h1&gt;&lt;comp-child val=\"\u305f\u3051\u3057\" \/&gt;&lt;\/div&gt;'\r\n})\r\n\r\nVue.component('comp-child', {\r\n  template: '&lt;p&gt;component\u306e\u5b50\uff1a{{ val }}&lt;\/p&gt;',\r\n\r\n  \/\/\u89aa\u304b\u3089\u53d7\u3051\u53d6\u308b\u5c5e\u6027\u540d\r\n  props: ['val']\r\n})\r\n\r\nnew Vue({\r\n  el: '#app'\r\n})\r\n\r\n&lt;\/script&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;<\/pre>\n<h3>\u5b9f\u884c\u4f8b<\/h3>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-5947\" src=\"http:\/\/www.code-magagine.com\/wp-content\/uploads\/2018\/07\/\u89aa\u5b50\u9593\u901a\u4fe1.png\" alt=\"\" width=\"303\" height=\"133\" srcset=\"http:\/\/www.code-magagine.com\/wp-content\/uploads\/2018\/07\/\u89aa\u5b50\u9593\u901a\u4fe1.png 303w, http:\/\/www.code-magagine.com\/wp-content\/uploads\/2018\/07\/\u89aa\u5b50\u9593\u901a\u4fe1-300x132.png 300w\" sizes=\"(max-width: 303px) 100vw, 303px\" \/><\/p>\n<h2>\u5b50\u304b\u3089\u89aa\u306e\u30a4\u30d9\u30f3\u30c8\u3092\u547c\u3076\u306b\u306f\uff1f<\/h2>\n<p>\u4e0b\u8a18\u306e\u4f8b\u306f\u3001\u5b50\u306e\u30af\u30ea\u30c3\u30af\u30a4\u30d9\u30f3\u30c8\u3092\u30c8\u30ea\u30ac\u30fc\u306b\u3057\u3066\u3001\u89aa\u3067\u5b9a\u7fa9\u3055\u308c\u3066\u3044\u308b\u30e1\u30bd\u30c3\u30c9\u3092\u547c\u3076\u5834\u5408\u306e\u30b5\u30f3\u30d7\u30eb\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true\">&lt;!DOCTYPE html&gt;\r\n&lt;html lang=\"ja\"&gt;\r\n&lt;head&gt;\r\n&lt;meta charset=\"UTF-8\" \/&gt;\r\n&lt;title&gt;test&lt;\/title&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n&lt;div id=\"app\"&gt;\r\n&lt;comp-child v-on:childevent=\"testMethod\"&gt;&lt;\/comp-child&gt;\r\n&lt;\/div&gt;\r\n&lt;script src=\"https:\/\/cdn.jsdelivr.net\/npm\/vue@2.5.13\/dist\/vue.js\"&gt;&lt;\/script&gt;\r\n&lt;script&gt;\r\n\r\nVue.component('comp-child', {\r\n  template: '&lt;button v-on:click=\"handleClick\"&gt;\u30a4\u30d9\u30f3\u30c8\u767a\u706b&lt;\/button&gt;',\r\n  methods: {\r\n    handleClick: function () {\r\n      this.$emit('childevent')\r\n    }\r\n  }\r\n})\r\n\r\nnew Vue({\r\n  el: '#app',\r\n  methods: {\r\n    testMethod: function () {\r\n      alert('\u30a4\u30d9\u30f3\u30c8\u304c\u767a\u751f')\r\n    }\r\n  }\r\n})\r\n\r\n&lt;\/script&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;<\/pre>\n<h3>\u30ab\u30b9\u30bf\u30e0\u30a4\u30d9\u30f3\u30c8<\/h3>\n<p>\u3053\u306e\u4f8b\u3067\u8a00\u3048\u3070\u3001<span style=\"color: #ff0000;\"><strong>\u300cv-on:childevent\u300d\u3068\u3044\u3046\u81ea\u4f5c\u306e\u30a4\u30d9\u30f3\u30c8\u306e\u3053\u3068\u3067\u3059\u3002<\/strong><\/span><\/p>\n<h3>$emit<\/h3>\n<p>\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u30e1\u30bd\u30c3\u30c9\u306e\u4e00\u3064\u3067\u3001\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306b\u7d10\u3065\u3044\u3066\u3044\u308b\u30a4\u30d9\u30f3\u30c8\u3092\u660e\u793a\u7684\u306b\u767a\u706b\u3055\u305b\u308b\u30e1\u30bd\u30c3\u30c9\u306b\u306a\u308a\u307e\u3059\u3002jQuery\u3067\u8a00\u3048\u3070\u3001trigger\u3068\u540c\u3058\u3088\u3046\u306a\u5f79\u5272\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u3053\u306e\u30b5\u30f3\u30d7\u30eb\u3067\u306f\u3001<span style=\"color: #ff0000;\"><strong>\u30dc\u30bf\u30f3\u304c\u62bc\u3055\u308c\u305f\u3089\u89aa\u304c\u5b50\u306e\u30a4\u30d9\u30f3\u30c8\u3092\u691c\u77e5\u3057\u3066\u3001\u30a2\u30e9\u30fc\u30c8\u3092\u8868\u793a\u3059\u308b<\/strong><\/span>\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u300c\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306e\u89aa\u5b50\u95a2\u4fc2\u300d\u3068\u306f\uff1f \u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3067\u4ed6\u306e\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3092\u4f7f\u3046\u3053\u3068\u3092\u3001\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306e\u89aa\u5b50\u95a2\u4fc2\u3068\u547c\u3073\u307e\u3059\u3002 Vue.js\u3067\u306f\u89aa\u304b\u3089\u5b50\u3078\u3057\u304b\u30c7\u30fc\u30bf\u3092\u53d7\u3051\u6e21\u3059\u3053\u3068\u304c\u3067\u304d\u307e\u305b\u3093\u3002\u5b50\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u304b\u3089 [&hellip;]","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[60],"tags":[],"_links":{"self":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/5939"}],"collection":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5939"}],"version-history":[{"count":14,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/5939\/revisions"}],"predecessor-version":[{"id":20639,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/5939\/revisions\/20639"}],"wp:attachment":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5939"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5939"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5939"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}