{"id":14257,"date":"2017-06-12T13:00:15","date_gmt":"2017-06-12T04:00:15","guid":{"rendered":"http:\/\/www.techscore.com\/blog\/?p=14257"},"modified":"2018-11-14T16:33:43","modified_gmt":"2018-11-14T07:33:43","slug":"vue-cli-%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%a6%e3%80%81%e3%82%b3%e3%83%b3%e3%83%9d%e3%83%bc%e3%83%8d%e3%83%b3%e3%83%88%e9%96%93%e3%81%a7%e3%83%87%e3%83%bc%e3%82%bf%e3%81%ae%e5%8f%97%e3%81%91%e6%b8%a1","status":"publish","type":"post","link":"https:\/\/www.techscore.com\/blog\/2017\/06\/12\/vue-cli-%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%a6%e3%80%81%e3%82%b3%e3%83%b3%e3%83%9d%e3%83%bc%e3%83%8d%e3%83%b3%e3%83%88%e9%96%93%e3%81%a7%e3%83%87%e3%83%bc%e3%82%bf%e3%81%ae%e5%8f%97%e3%81%91%e6%b8%a1\/","title":{"rendered":"vue-cli \u3092\u4f7f\u3063\u3066\u3001\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u9593\u3067\u30c7\u30fc\u30bf\u306e\u53d7\u3051\u6e21\u3057\u3092\u3059\u308b\u30a2\u30d7\u30ea\u3092\u4f5c\u6210\u3057\u3066\u307f\u308b"},"content":{"rendered":"<p>\u3053\u3093\u306b\u3061\u306f\u3001\u5e73\u5965\u3067\u3059\uff01<\/p>\n<p>\u6700\u8fd1\u306e\u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9\u958b\u767a\u3067\u306f\u3001\u30b7\u30f3\u30b0\u30eb\u30da\u30fc\u30b8\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3( SPA )\u304c\u4e3b\u6d41\u306b\u306a\u3063\u3066\u304d\u3066\u304a\u308a\u3001\u305d\u308c\u3092\u5b9f\u73fe\u3059\u308b\u305f\u3081\u306b JavaScript \u306e\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u304c\u6b20\u304b\u305b\u306a\u3044\u3082\u306e\u3068\u306a\u3063\u3066\u304d\u307e\u3057\u305f\u3002<br \/>\nReact\u3001AngularJS\u3001Angular\u3001Vue.js\u3001Backbone.js\u3001Riot.js\u3001Aurelia.js\u3001Ember.js...<br \/>\n\u3044\u308d\u3093\u306a\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u304c\u3053\u3053\u6570\u5e74\u3067\u4e16\u306e\u4e2d\u306b\u51fa\u3066\u304d\u307e\u3057\u305f\u3002\u305d\u308c\u305e\u308c\u306e\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3067\u3001\u7279\u5fb4\u3084\u4ed6\u306e\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3088\u308a\u512a\u308c\u3066\u3044\u308b\u6a5f\u80fd\u3001\u5b66\u7fd2\u30b3\u30b9\u30c8\u3001\u30e1\u30f3\u30c6\u30ca\u30f3\u30b9\u6027\u3001\u958b\u767a\u52b9\u7387\u304c\u9055\u3063\u3066\u304d\u307e\u3059\u3002<\/p>\n<p>\u305d\u3053\u3067\u4eca\u56de\u306f\u6700\u8fd1\u52e2\u3044\u306e\u3042\u308b Vue.js \u3067\u7c21\u5358\u306a\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u4f5c\u3063\u3066\u307f\u3066\u3001\u4eca\u4f7f\u3063\u3066\u3044\u308b\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3068\u3069\u3046\u9055\u3046\u306e\u304b\u6bd4\u8f03\u3057\u3066\u307f\u3088\u3046\u3068\u601d\u3044\u307e\u3057\u305f\u3002\u305d\u308c\u3067\u306f\u65e9\u901f\u3044\u3063\u3066\u307f\u307e\u3057\u3087\u3046\uff01<\/p>\n<h2>\u6e96\u5099<\/h2>\n<p>\u307e\u305a\u958b\u767a\u74b0\u5883\u3092\u6574\u3048\u307e\u3059\u3002vue \u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u304b\u3089\u59cb\u307e\u308a\u3001\u4eca\u56de\u306f\u304a\u624b\u8efd\u306b Vue.js \u3092\u59cb\u3081\u3089\u308c\u308b\u3088\u3046\u306b <a href=\"https:\/\/jp.vuejs.org\/2015\/12\/28\/vue-cli\/\">vue-cli<\/a> \u3092\u4f7f\u7528\u3057\u307e\u3059\u3002<br \/>\n\u307e\u305f <a href=\"https:\/\/v4-alpha.getbootstrap.com\">Bootstrap<\/a> \u3082\u4f7f\u3048\u308b\u3088\u3046\u306b\u3057\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n<p>Vue.js \u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/p>\n<pre>$ npm install vue<\/pre>\n<p>vue-cli \u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u3001vue-sample \u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3092\u4f5c\u6210<\/p>\n<pre># vue-cli \u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\r\n$ npm install --global vue-cli\r\n# \"webpack\" \u30dc\u30a4\u30e9\u30fc\u30d7\u30ec\u30fc\u30c8\u3092\u4f7f\u7528\u3057\u305f\u65b0\u3057\u3044\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3092\u4f5c\u6210\u3059\u308b\r\n$ vue init webpack vue-sample\r\n# \u4f9d\u5b58\u95a2\u4fc2\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066go!\r\n$ cd vue-sample\r\n$ npm install\r\n$ npm run dev\r\n<\/pre>\n<p>Bootstrap \u3068 Bootstrap-vue \u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/p>\n<pre>\r\nnpm install bootstrap@4.0.0-alpha.6\r\nnpm install --save bootstrap-vue\r\n<\/pre>\n<p><a href=\"https:\/\/bootstrap-vue.github.io\"> Bootstrap-vue <\/a><\/p>\n<p>\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u4f5c\u6210\u6642\u306b\u4ee5\u4e0b\u306e\u9078\u629e\u304c\u8868\u793a\u3055\u308c\u307e\u3059\u304c\u3001\u3059\u3079\u3066 'Y' \u3092\u5165\u529b\u3057\u3066\u3082\u5927\u4e08\u592b\u3067\u3059\u3002<br \/>\n\u4eca\u56de\u306f vue-router \u3082\u4f7f\u3044\u305f\u3044\u306e\u3067 Install vue-router? \u306e\u7b87\u6240\u3067\u306f 'Y' \u3092\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p><a href=\"https:\/\/www.techscore.com\/blog\/wp\/wp-content\/uploads\/2017\/06\/vue-cli.png\" rel=\"facebox\" rel=\"attachment wp-att-14272\"><img loading=\"lazy\" src=\"https:\/\/www.techscore.com\/blog\/wp\/wp-content\/uploads\/2017\/06\/vue-cli.png\" alt=\"\" width=\"400\" height=\"110\" class=\"alignnone size-full wp-image-14272\" srcset=\"https:\/\/www.techscore.com\/blog\/wp\/wp-content\/uploads\/2017\/06\/vue-cli.png 400w, https:\/\/www.techscore.com\/blog\/wp\/wp-content\/uploads\/2017\/06\/vue-cli-300x83.png 300w\" sizes=\"(max-width: 400px) 100vw, 400px\" \/><\/a><\/p>\n<p>\u4ee5\u4e0a\u3067\u6e96\u5099\u306f\u5b8c\u4e86\u3067\u3059\u3002<\/p>\n<p>\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u69cb\u6210\u3067\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u304c\u4f5c\u6210\u3055\u308c\u307e\u3059\u3002<br \/>\n\u3053\u308c\u3092\u57fa\u306b\u3057\u3066\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u4f5c\u6210\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<p><a href=\"https:\/\/www.techscore.com\/blog\/wp\/wp-content\/uploads\/2017\/06\/vue-cli-directory.png\" rel=\"facebox\" rel=\"attachment wp-att-14276\"><img loading=\"lazy\" src=\"https:\/\/www.techscore.com\/blog\/wp\/wp-content\/uploads\/2017\/06\/vue-cli-directory.png\" alt=\"\" width=\"203\" height=\"687\" class=\"alignnone size-full wp-image-14276\" srcset=\"https:\/\/www.techscore.com\/blog\/wp\/wp-content\/uploads\/2017\/06\/vue-cli-directory.png 203w, https:\/\/www.techscore.com\/blog\/wp\/wp-content\/uploads\/2017\/06\/vue-cli-directory-89x300.png 89w\" sizes=\"(max-width: 203px) 100vw, 203px\" \/><\/a><\/p>\n<h2>\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u4f5c\u308b\u306b\u3042\u305f\u3063\u3066<\/h2>\n<p><a href=\"https:\/\/jp.vuejs.org\">\u516c\u5f0f\u30b5\u30a4\u30c8<\/a>\u306b\u60c5\u5831\u304c\u8c4a\u5bcc\u306b\u8f09\u305b\u3089\u308c\u3066\u304a\u308a\u3001\u307e\u305f\u65e5\u672c\u8a9e\u306b\u3082\u7ffb\u8a33\u3055\u308c\u3066\u3044\u307e\u3059\u3002\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u4f5c\u6210\u3059\u308b\u306b\u306f\u516c\u5f0f\u30b5\u30a4\u30c8\u3092\u53c2\u8003\u306b\u3057\u3066\u4f5c\u6210\u3059\u308b\u306e\u304c\u3088\u3044\u304b\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>\u4eca\u56de\u306f\u30d5\u30a9\u30fc\u30e0\u753b\u9762\u3068\u30ea\u30b9\u30c8\u753b\u9762\u3092\u4f5c\u6210\u3057\u3001\u30d5\u30a9\u30fc\u30e0\u753b\u9762\u3067\u767b\u9332\u3057\u305f\u5185\u5bb9\u3092\u30ea\u30b9\u30c8\u306b\u8868\u793a\u3059\u308b\u7c21\u5358\u306a\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u4f5c\u6210\u3057\u3066\u307f\u3088\u3046\u3068\u8003\u3048\u3066\u3044\u307e\u3059\u3002<br \/>\n\u753b\u9762\u306f router \u3092\u4f7f\u3063\u3066\u5207\u308a\u66ff\u3048\u308b\u3088\u3046\u306b\u3067\u304d\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/p>\n<h2>\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u4f5c\u6210<\/h2>\n<h3>\u5358\u4e00\u30d5\u30a1\u30a4\u30eb\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3067\u753b\u9762\u306e\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3092\u4f5c\u6210<\/h3>\n<p>\u30d5\u30a9\u30fc\u30e0\u753b\u9762\u3068\u30ea\u30b9\u30c8\u753b\u9762\u306f\u5358\u4e00\u30d5\u30a1\u30a4\u30eb\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3067\u4f5c\u6210\u3057\u307e\u3059\u3002\u305d\u308c\u305e\u308c Add.vue \u3068 List.vue \u3068\u3044\u3046\u540d\u524d\u306b\u3057\u307e\u3059\u3002<br \/>\n\u666e\u901a\u306e\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3068\u5358\u4e00\u30d5\u30a1\u30a4\u30eb\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306f\u3001\u540c\u3058\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3068\u306a\u308a\u307e\u3059\u304c\u3001\u5358\u4e00\u30d5\u30a1\u30a4\u30eb\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306f HTML\u3001JS\u3001CSS\u3092\u3072\u3068\u307e\u3068\u3081\u306b\u3067\u304d\u305f\u308a\u3001\u30b0\u30ed\u30fc\u30d0\u30eb\u3092\u6c5a\u67d3\u3057\u306a\u3044\u7b49\u306e\u30e1\u30ea\u30c3\u30c8\u304c\u3042\u308a\u307e\u3059\u3002HTML \u306f \"template\" \u30bf\u30b0\u306e\u4e2d\u306b\u8a18\u8ff0\u3057\u3001JS \u306f \"script\" \u3001CSS \u306f \"style\" \u30bf\u30b0\u306e\u4e2d\u306b\u8a18\u8f09\u3057\u307e\u3059\u3002<br \/>\n\u8a73\u3057\u304f\u306f\u3001\u516c\u5f0f\u30da\u30fc\u30b8\u306e<a href=\"https:\/\/jp.vuejs.org\/v2\/guide\/single-file-components.html\"> \u5358\u4e00\u30d5\u30a1\u30a4\u30eb\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8 <\/a> \u3092\u53c2\u7167\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p><strong>components \u30d5\u30a9\u30eb\u30c0\u306b Add.vue \u3068 List.vue \u30d5\u30a1\u30a4\u30eb\u3092\u8ffd\u52a0<\/strong><br \/>\n<a href=\"https:\/\/www.techscore.com\/blog\/wp\/wp-content\/uploads\/2017\/06\/Add-List.png\" rel=\"facebox\" rel=\"attachment wp-att-14286\"><img loading=\"lazy\" src=\"https:\/\/www.techscore.com\/blog\/wp\/wp-content\/uploads\/2017\/06\/Add-List.png\" alt=\"\" width=\"261\" height=\"186\" class=\"alignnone size-full wp-image-14286\" \/><\/a><\/p>\n<h3>\u30d5\u30a9\u30fc\u30e0\u753b\u9762\u306e\u4f5c\u6210<\/h3>\n<p>Add.vue \u30d5\u30a1\u30a4\u30eb\u3092\u4f7f\u3063\u3066\u30d5\u30a9\u30fc\u30e0\u753b\u9762\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<p>\"template\" \u306f\u4ee5\u4e0b\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>\r\n<template>\r\n  <div id=\"app\">\r\n    <form>\r\n      <h3>\u25a0 \u30c7\u30fc\u30bf\u767b\u9332<\/h3>\r\n      <input-name><\/input-name>\r\n      <input-age><\/input-age>\r\n      <input-mail><\/input-mail>\r\n      <br>\r\n      <input-button><\/input-button>\r\n    <\/form>\r\n  <\/div>\r\n<\/template>\r\n<\/pre>\n<p>\"input-name\"\u3001\"input-age\"\u3001\"input-mail\"\u3001\"input-button\" \u306f\u30ab\u30b9\u30bf\u30e0\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3067\u72ec\u81ea\u3067\u5b9a\u7fa9\u3057\u305f\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3068\u306a\u308a\u307e\u3059\u3002\u4ee5\u4e0b\u306e \"script\" \u30bf\u30b0\u306e\u3068\u3053\u308d\u3067\u8a73\u3057\u304f\u8aac\u660e\u3057\u307e\u3059\u3002<\/p>\n<p>\"script\" \u306f\u4ee5\u4e0b\u3068\u306a\u308a\u307e\u3059\u3002\u30ab\u30b9\u30bf\u30e0\u30bf\u30b0\u3092\u5b9a\u7fa9\u3057\u3066\u3001\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3092\u767b\u9332\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<pre>\r\n<script>\r\nimport Vue from 'vue'\r\nexport default {\r\n\r\n}\r\nimport PropertyStore from '..\/models\/store.js'\r\nimport Bus from '..\/models\/bus.js'\r\n\r\nvar InputName = Vue.extend({\r\n  name: 'input_name',\r\n  template: '<div class=\"form-gxroup\"><label for=\"Name\">Name<\/label><input type=\"text\" v-model=\"sharedState.state.property.name\" class=\"form-control\" id=\"Name\"><\/div>',\r\n  data: function () {\r\n    return {\r\n      privateState: {},\r\n      sharedState: PropertyStore\r\n    }\r\n  }\r\n})\r\n\/\/  \u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3092\u767b\u9332\r\nVue.component('input-name', InputName)\r\n\r\nvar InputAge = Vue.extend({\r\n  name: 'input_age',\r\n  template: '<div class=\"form-gxroup\"><label for=\"Age\">Age<\/label><input type=\"text\" v-model=\"sharedState.state.property.age\" class=\"form-control\" id=\"Age\"><\/div>',\r\n  data: function () {\r\n    return {\r\n      privateState: {},\r\n      sharedState: PropertyStore\r\n    }\r\n  }\r\n})\r\n\/\/  \u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3092\u767b\u9332\r\nVue.component('input-age', InputAge)\r\n\r\nvar InputMail = Vue.extend({\r\n  name: 'input_mail',\r\n  template: '<div class=\"form-gxroup\"><label for=\"Mail\">Mail Address<\/label><input type=\"text\" v-model=\"sharedState.state.property.mail\" class=\"form-control\" id=\"Mail\"><\/div>',\r\n  data: function () {\r\n    return {\r\n      privateState: {},\r\n      sharedState: PropertyStore\r\n    }\r\n  }\r\n})\r\n\/\/  \u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3092\u767b\u9332\r\nVue.component('input-mail', InputMail)\r\n\r\n\/\/ \u30dc\u30bf\u30f3\u306e\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3092\u4f5c\u6210\r\nvar InputButton = Vue.extend({\r\n  name: 'input-button',\r\n  template: '<button class=\"btn btn-primary\" v-on:click=\"save\">Regist<\/button>',\r\n  data: function () {\r\n    return {\r\n      privateState: {},\r\n      sharedState: PropertyStore\r\n    }\r\n  },\r\n  methods: {\r\n    save: function (event) {\r\n      console.log(PropertyStore.state.property.name)\r\n      console.log(PropertyStore.state.property.age)\r\n      console.log(PropertyStore.state.property.mail)\r\n\r\n      \/\/ emit\r\n      Bus.$emit('store-update', 'Add.vue')\r\n\r\n      \/\/ \u30ea\u30c0\u30a4\u30ec\u30af\u30c8\r\n      this.$router.push('\/List')\r\n    }\r\n  }\r\n})\r\n\/\/  \u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3092\u767b\u9332\r\nVue.component('input-button', InputButton)\r\n<\/script>\r\n<\/pre>\n<p>\u3053\u3053\u3067\u306f\u5927\u304d\u304f\u5206\u3051\u3066\u3001\u30c6\u30ad\u30b9\u30c8\u5165\u529b\u306e\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3068\u30dc\u30bf\u30f3\u306e\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3092\u4f5c\u6210\u3057\u3066\u3044\u307e\u3059\u3002\u305d\u308c\u305e\u308c\u8aac\u660e\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<h4>\u30c6\u30ad\u30b9\u30c8\u5165\u529b\u306e\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8<\/h4>\n<p>\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306f Vue.extend \u3067\u4f5c\u6210\u3057\u307e\u3059\u3002\u3053\u306e\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3067\u306f name\u3001template\u3001data \u3092\u4f7f\u7528\u3057\u3066\u3044\u307e\u3059\u3002<br \/>\n\u305d\u308c\u305e\u308c\u540d\u524d\u3092\u5b9a\u7fa9\u3001\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306e HTML \u3092\u5b9a\u7fa9\u3001\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3067\u4f7f\u7528\u3059\u308b\u30c7\u30fc\u30bf\u3092\u5b9a\u7fa9\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u3053\u3053\u3067\u306f v-model \u3092\u4f7f\u3063\u3066\u30c6\u30ad\u30b9\u30c8\u30dc\u30c3\u30af\u30b9\u306b\u5165\u529b\u3055\u308c\u305f\u60c5\u5831\u3092 data \u306e PropertyStore \u306b\u4fdd\u5b58\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<h4>\u30dc\u30bf\u30f3\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8<\/h4>\n<p>\u30dc\u30bf\u30f3\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3067\u306f name\u3001template\u3001data\u3001methods \u3092\u4f7f\u7528\u3057\u3066\u3044\u307e\u3059\u3002<br \/>\nname\u3001template\u3001data \u306f\u30c6\u30ad\u30b9\u30c8\u5165\u529b\u306e\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3067\u8aac\u660e\u3057\u305f\u306e\u3067\u3001methods \u3092\u8aac\u660e\u3057\u307e\u3059\u3002<br \/>\nmethods \u3067\u306f\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306b\u7d44\u307f\u8fbc\u307e\u308c\u308b\u30e1\u30bd\u30c3\u30c9\u3092\u5b9a\u7fa9\u3057\u307e\u3059\u3002<\/p>\n<p>\u3053\u3053\u3067\u306f \u30dc\u30bf\u30f3\u304c\u62bc\u3055\u308c\u305f\u6642\u306e\u30e1\u30bd\u30c3\u30c9\u3067\u3042\u308b save \u30e1\u30bd\u30c3\u30c9\u3092\u5b9a\u7fa9\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<h3>\u30ea\u30b9\u30c8\u753b\u9762\u306e\u4f5c\u6210<\/h3>\n<p>List.vue \u30d5\u30a1\u30a4\u30eb\u3092\u4f7f\u3063\u3066\u30ea\u30b9\u30c8\u753b\u9762\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<p>\"template\" \u306f\u4ee5\u4e0b\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>\r\n<template>\r\n  <div id=\"app\">\r\n    <h3>\u25a0 \u767b\u9332\u30c7\u30fc\u30bf\u4e00\u89a7<\/h3>\r\n    <grid-component><\/grid-component>\r\n  \r\n  <\/div>\r\n<\/template>\r\n<\/pre>\n<p>\u3053\u3053\u3067\u306f\u30ea\u30b9\u30c8\u3092\u8868\u793a\u3059\u308b\u305f\u3081\u306e grid-component \u304c\u5b9a\u7fa9\u3055\u308c\u3066\u3044\u307e\u3059\u3002<br \/>\ngrid-component \u306f\u4ee5\u4e0b\u306b\u8aac\u660e\u3059\u308b \"script\" \u306b\u5b9a\u7fa9\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<pre>\r\n<script>\r\n\/\/ \u30a4\u30f3\u30dd\u30fc\u30c8\r\nimport Vue from 'vue'\r\nimport Bus from '..\/models\/bus.js'\r\nimport {Grid} from '..\/grid\/grid.js'\r\nimport PropertyStore from '..\/models\/store.js'\r\n\r\nexport default {\r\n  name: 'List'\r\n}\r\n\r\nvar receiveData = []\r\n\r\nVue.component('grid-component', {\r\n  template: '<demo-grid :data=\"gridData\" :columns=\"gridColumns\" :filter-key=\"searchQuery\"><\/demo-grid>',\r\n  data: function () {\r\n    return {\r\n      searchQuery: '',\r\n      gridColumns: ['name', 'age', 'mailAddress'],\r\n      \/\/ gridData: [{name: PropertyStore.state.property.name, age: PropertyStore.state.property.age, mailAddress: PropertyStore.state.property.mail}]\r\n      gridData: receiveData\r\n    }\r\n  }\r\n})\r\n\r\n\/\/ \u30e1\u30c3\u30bb\u30fc\u30b8\u53d7\u53d6\r\nBus.$on('store-update', (vue) => {\r\n  console.log(vue)\r\n  receiveData.push({name: PropertyStore.state.property.name, age: PropertyStore.state.property.age, mailAddress: PropertyStore.state.property.mail})\r\n})\r\n\r\n\/\/ \u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3092\u767b\u9332\r\nVue.component('grid', Grid)\r\n<\/script>\r\n<\/pre>\n<p>\u57fa\u672c\u7684\u306b\u306f\u3001\u3084\u3063\u3066\u3044\u308b\u3053\u3068\u306f\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306e\u5b9a\u7fa9\u3068\u767b\u9332\u3067\u3042\u308a\u3001\u30d5\u30a9\u30fc\u30e0\u753b\u9762\u3068\u3055\u307b\u3069\u5909\u308f\u308a\u307e\u305b\u3093\u3002<br \/>\n\u305f\u3060\u3057\u3001\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3092 import \u3092\u4f7f\u3063\u3066\u53d6\u308a\u8fbc\u3093\u3067\u3044\u305f\u308a\u3001\u30e1\u30c3\u30bb\u30fc\u30b8\u53d7\u53d6\u7528\u306e\u51e6\u7406\u304c\u5b9f\u88c5\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u3053\u3061\u3089\u3082 \"styles\" \u306b\u95a2\u3057\u3066\u306f\u91cd\u8981\u3067\u306f\u306a\u3044\u306e\u3067\u8aac\u660e\u306f\u5272\u611b\u3055\u305b\u3066\u3044\u305f\u3060\u304d\u307e\u3059\u3002<\/p>\n<h3>\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u9593\u306e\u30c7\u30fc\u30bf\u306e\u53d7\u3051\u6e21\u3057\u306b\u3064\u3044\u3066<\/h3>\n<p>\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u9593\u306e\u30c7\u30fc\u30bf\u306e\u53d7\u3051\u6e21\u3057\u306f\u30a4\u30d9\u30f3\u30c8\u3092\u4f7f\u3046\u65b9\u6cd5\u3068\u5171\u901a\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u4f7f\u3063\u3066\u53d7\u3051\u6e21\u3059\u65b9\u6cd5\u3092\u8a66\u3057\u3066\u307f\u305f\u304b\u3063\u305f\u306e\u3067\u4e21\u65b9\u3068\u3082\u5b9f\u88c5\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>\u307e\u305a\u3001\u5171\u901a\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u4f7f\u3063\u3066\u53d7\u3051\u6e21\u3059\u65b9\u6cd5\u3067\u3059\u304c\u3001\u65b0\u305f\u306b models \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u4f5c\u6210\u3057\u3066\u3001\u305d\u306e\u4e2d\u306b\u5171\u901a\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u5b9a\u7fa9\u3057\u305f store.js \u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>store.js \u30d5\u30a1\u30a4\u30eb\u306e\u5b9f\u88c5\u306f\u4ee5\u4e0b\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>\r\nvar PropertyStore = {\r\n  debug: true,\r\n  state: {\r\n    property: {\r\n      name: '',\r\n      age: '',\r\n      mail: ''\r\n    }\r\n  }\r\n}\r\nexport default PropertyStore\r\n\r\n<\/pre>\n<p>\u5171\u901a\u3067\u53d7\u3051\u6e21\u3057\u305f\u3044\u30c7\u30fc\u30bf\u3092\u4fdd\u6301\u3059\u308b\u5909\u6570\u3092\u5b9a\u7fa9\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u3053\u306e PropertyStore \u3092\u4f7f\u3063\u3066\u30c7\u30fc\u30bf\u3092\u53d7\u3051\u6e21\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u30c7\u30fc\u30bf\u3092\u9001\u308b\u5074\u306e Add.vue \u306e\u5b9f\u88c5<\/p>\n<pre>\r\n\/\/ \u5171\u901a\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u30a4\u30f3\u30dd\u30fc\u30c8\r\nimport PropertyStore from '..\/models\/store.js'\r\n\r\n\/\/ data \u3092\u4f7f\u3063\u3066\u5171\u901a\u30e2\u30b8\u30e5\u30fc\u30eb\u306b\u30c7\u30fc\u30bf\u3092\u8a2d\u5b9a\r\nvar InputName = Vue.extend({\r\n  name: 'input_name',\r\n  template: '<div class=\"form-gxroup\"><label for=\"Name\">Name<\/label><input type=\"text\" v-model=\"sharedState.state.property.name\" class=\"form-control\" id=\"Name\"><\/div>',\r\n  data: function () {\r\n    return {\r\n      privateState: {},\r\n      sharedState: PropertyStore\r\n    }\r\n  }\r\n})\r\n<\/pre>\n<p>\u53d7\u3051\u53d6\u308b\u5074\u306e List.vue \u306e\u5b9f\u88c5<\/p>\n<pre>\r\n\/\/ \u5171\u901a\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u30a4\u30f3\u30dd\u30fc\u30c8\r\nimport PropertyStore from '..\/models\/store.js'\r\n\r\nVue.component('grid-component', {\r\n  template: '<demo-grid :data=\"gridData\" :columns=\"gridColumns\" :filter-key=\"searchQuery\"><\/demo-grid>',\r\n  data: function () {\r\n    return {\r\n      searchQuery: '',\r\n      gridColumns: ['name', 'age', 'mailAddress'],\r\n      gridData: [{name: PropertyStore.state.property.name, age: PropertyStore.state.property.age, mailAddress: PropertyStore.state.property.mail}]\r\n      \/\/ gridData: receiveData\r\n    }\r\n  }\r\n})\r\n<\/pre>\n<p>\u3053\u3061\u3089\u306e\u53d7\u3051\u53d6\u308a\u65b9\u3067\u306f\u5171\u901a\u30e2\u30b8\u30e5\u30fc\u30eb\u306e\u69cb\u9020\u4e0a1\u4ef6\u306e\u30c7\u30fc\u30bf\u3057\u304b\u767b\u9332\u3067\u304d\u307e\u305b\u3093\u3002\u30a4\u30d9\u30f3\u30c8\u3067\u4f7f\u3046\u5171\u901a\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3068\u4e00\u7dd2\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u4f7f\u3044\u305f\u304b\u3063\u305f\u306e\u3067\u3001\u3053\u306e\u3088\u3046\u306a\u4ed5\u69d8\u306b\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>\u6b21\u306b\u30a4\u30d9\u30f3\u30c8\u3092\u4f7f\u3063\u3066\u30c7\u30fc\u30bf\u3092\u53d7\u3051\u6e21\u3059\u65b9\u6cd5\u3067\u3059\u3002<\/p>\n<p>\u30c7\u30fc\u30bf\u3092\u9001\u4fe1\u3059\u308b\u5074\u306e Add.js \u3067 $emit \u3092\u4f7f\u3063\u3066\u30a4\u30d9\u30f3\u30c8\u3092\u767a\u706b\u3057\u3066\u3044\u307e\u3059\u3002\u3061\u306a\u307f\u306b $emit \u306e\u7b2c2\u30d1\u30e9\u30e1\u30fc\u30bf\u306b\u6307\u5b9a\u3057\u305f\u30c7\u30fc\u30bf\u3092\u9001\u4fe1\u3067\u304d\u308b\u306e\u3067\u3059\u304c\u3001<br \/>\n\u4eca\u56de\u306f\u5171\u901a\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u53c2\u7167\u3055\u305b\u308b\u3088\u3046\u306b\u3057\u307e\u3057\u305f\u3002<\/p>\n<pre>\r\n\/\/ \u30dc\u30bf\u30f3\u306e\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3092\u4f5c\u6210\r\nvar InputButton = Vue.extend({\r\n  name: 'input-button',\r\n  template: '<button class=\"btn btn-primary\" v-on:click=\"save\">Regist<\/button>',\r\n  data: function () {\r\n    return {\r\n      privateState: {},\r\n      sharedState: PropertyStore\r\n    }\r\n  },\r\n  methods: {\r\n    save: function (event) {\r\n      console.log(PropertyStore.state.property.name)\r\n      console.log(PropertyStore.state.property.age)\r\n      console.log(PropertyStore.state.property.mail)\r\n\r\n      \/\/ emit\r\n      Bus.$emit('store-update', 'Add.vue')\r\n\r\n      \/\/ \u30ea\u30c0\u30a4\u30ec\u30af\u30c8\r\n      this.$router.push('\/List')\r\n    }\r\n  }\r\n})\r\n<\/pre>\n<p>\u53d7\u3051\u53d6\u308a\u5074\u306e List.vue \u3067\u306f $on \u3092\u4f7f\u3063\u3066\u30a4\u30d9\u30f3\u30c8\u3092\u53d7\u3051\u53d6\u3063\u3066\u3044\u307e\u3059\u3002\u53d7\u3051\u53d6\u3063\u305f\u30c7\u30fc\u30bf\u306f data \u3092\u4f7f\u3063\u3066\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306b\u6e21\u3057\u3066\u30ea\u30b9\u30c8\u8868\u793a\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<pre>\r\nvar receiveData = []\r\n\r\nVue.component('grid-component', {\r\n  template: '<demo-grid :data=\"gridData\" :columns=\"gridColumns\" :filter-key=\"searchQuery\"><\/demo-grid>',\r\n  data: function () {\r\n    return {\r\n      searchQuery: '',\r\n      gridColumns: ['name', 'age', 'mailAddress'],\r\n      \/\/ gridData: [{name: PropertyStore.state.property.name, age: PropertyStore.state.property.age, mailAddress: PropertyStore.state.property.mail}]\r\n      gridData: receiveData\r\n    }\r\n  }\r\n})\r\n\r\n\/\/ \u30e1\u30c3\u30bb\u30fc\u30b8\u53d7\u53d6\r\nBus.$on('store-update', (vue) => {\r\n  console.log(vue)\r\n  receiveData.push({name: PropertyStore.state.property.name, age: PropertyStore.state.property.age, mailAddress: PropertyStore.state.property.mail})\r\n})\r\n<\/pre>\n<h2>\u307e\u3068\u3081<\/h2>\n<p>\u4eca\u56de\u306f\u3056\u3063\u304f\u308a Vue.js \u304c\u3069\u3046\u3044\u3046\u3082\u306e\u306a\u306e\u304b\u3068\u3044\u3046\u3053\u3068\u3092\u307e\u305a\u306f\u89e6\u3063\u3066\u307f\u3088\u3046\u3068\u3044\u3046\u3053\u3068\u3067\u3001\u30b5\u30f3\u30d7\u30eb\u30a2\u30d7\u30ea\u3092\u4f5c\u6210\u3057\u307e\u3057\u305f\u3002<br \/>\nVue.js \u306e\u7279\u5fb4\u3067\u3042\u308b MVVM \u306e\u8a2d\u8a08\u30d1\u30bf\u30fc\u30f3\u306b\u306f\u89e6\u308c\u3066\u3044\u306a\u3044\u306e\u3067\u3001\u3053\u306e\u8a2d\u8a08\u30d1\u30bf\u30fc\u30f3\u3092\u4f7f\u3063\u3066\u5b9f\u88c5\u3059\u308c\u3070\u3082\u3063\u3068\u30c7\u30fc\u30bf\u304c\u6271\u3044\u3084\u3059\u304f\u306a\u308b\u306e\u304b\u306a\u3068\u601d\u3044\u307e\u3057\u305f\u3002<br \/>\n\u307e\u305f redux \u3092\u5b9f\u73fe\u3059\u308b vuex \u306a\u3069\u3082\u3042\u308a\u307e\u3059\u306e\u3067\u4eca\u5f8c\u4f7f\u3063\u3066\u307f\u3088\u3046\u3068\u601d\u3044\u307e\u3059\u3002<br \/>\n\u3044\u308d\u3093\u306a\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u306b\u89e6\u308c\u3066\u3001\u305d\u306e\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u306e\u601d\u60f3\u3084\u8003\u3048\u65b9\u306b\u89e6\u308c\u3066\u307f\u308b\u306e\u3082\u3088\u3044\u6a5f\u4f1a\u3060\u3068\u611f\u3058\u307e\u3057\u305f\u3002<\/p>\n<p><a href=\"https:\/\/github.com\/s-hiraoku\/vue-sample\">\u4eca\u56de\u4f5c\u6210\u3057\u305f\u30b5\u30f3\u30d7\u30eb\u30bd\u30fc\u30b9\u306f\u3053\u3061\u3089<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3053\u3093\u306b\u3061\u306f\u3001\u5e73\u5965\u3067\u3059\uff01<\/p>\n<p>\u6700\u8fd1\u306e\u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9\u958b\u767a\u3067\u306f\u3001\u30b7\u30f3\u30b0\u30eb\u30da\u30fc\u30b8\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3( SPA )\u304c\u4e3b\u6d41\u306b\u306a\u3063\u3066\u304d\u3066\u304a\u308a\u3001\u305d\u308c\u3092\u5b9f\u73fe\u3059\u308b\u305f\u3081\u306b JavaScript \u306e\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u304c\u6b20\u304b\u305b\u306a\u3044\u3082\u306e\u3068\u306a\u3063\u3066\u304d\u307e\u3057\u305f\u3002<br \/><a href=\"https:\/\/www.techscore.com\/blog\/2017\/06\/12\/vue-cli-%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%a6%e3%80%81%e3%82%b3%e3%83%b3%e3%83%9d%e3%83%bc%e3%83%8d%e3%83%b3%e3%83%88%e9%96%93%e3%81%a7%e3%83%87%e3%83%bc%e3%82%bf%e3%81%ae%e5%8f%97%e3%81%91%e6%b8%a1\/\">\u7d9a\u304d\u3092\u8aad\u3080...<\/a><\/p>\n","protected":false},"author":29,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[18],"tags":[269,268],"_links":{"self":[{"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/posts\/14257"}],"collection":[{"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/users\/29"}],"replies":[{"embeddable":true,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/comments?post=14257"}],"version-history":[{"count":60,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/posts\/14257\/revisions"}],"predecessor-version":[{"id":14320,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/posts\/14257\/revisions\/14320"}],"wp:attachment":[{"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/media?parent=14257"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/categories?post=14257"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/tags?post=14257"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}