{"id":1943,"date":"2018-11-01T03:07:21","date_gmt":"2018-10-31T18:07:21","guid":{"rendered":"https:\/\/blog.capilano-fw.com\/?p=1943"},"modified":"2018-11-01T03:07:21","modified_gmt":"2018-10-31T18:07:21","slug":"vue-component-%e3%81%a7%e5%92%8c%e6%9a%a6%e3%81%8b%e3%82%89%e8%a5%bf%e6%9a%a6%e3%81%ab%e5%a4%89%e6%8f%9b%e3%81%99%e3%82%8b%e3%82%bb%e3%83%ac%e3%82%af%e3%83%88%e3%83%9c%e3%83%83%e3%82%af%e3%82%b9","status":"publish","type":"post","link":"https:\/\/blog.capilano-fw.com\/?p=1943","title":{"rendered":"Vue Component \u3067\u548c\u66a6\u304b\u3089\u897f\u66a6\u306b\u5909\u63db\u3059\u308b\u30bb\u30ec\u30af\u30c8\u30dc\u30c3\u30af\u30b9\u3092\u3064\u304f\u308b"},"content":{"rendered":"<p>\u3055\u3066\u3055\u3066\u3001\u524d\u56de\u306e\u8a18\u4e8b\u300c<a href=\"https:\/\/blog.capilano-fw.com\/?p=1928\">Vue Component \u3067\uff12\u679a\u306e\u753b\u50cf\u3092\u5207\u308a\u66ff\u3048\u308b\u30c1\u30a7\u30c3\u30af\u30dc\u30c3\u30af\u30b9\u3092\u3064\u304f\u3063\u3066\u307f\u3088\u3046<\/a>\u300d\u3067\u306f\u72ec\u81ea\u306e\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\uff08\u2252\u7591\u4f3cHTML\u30bf\u30b0\uff09\u3092\u4f5c\u3063\u3066\u5229\u7528\u898f\u7d04\u306e\u540c\u610f\u3067\u4f7f\u3063\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<p>\u305d\u3057\u3066\u3001\u3053\u306e\u8a18\u4e8b\u3092\u66f8\u3044\u3066\u3044\u308b\u6642\u306b\u3001\u305d\u306e\u6614\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u3055\u3093\u304b\u3089\u3054\u8981\u671b\u304c\u3042\u3063\u305f\u300c\u3061\u3087\u3063\u3068\u3081\u3093\u3069\u3046\u306a\u300d\u30bb\u30ec\u30af\u30c8\u30dc\u30c3\u30af\u30b9\u304c\u3042\u3063\u305f\u3053\u3068\u3092\u601d\u3044\u51fa\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>\u305d\u308c\u304c\u3001<strong>\u5143\u53f7 + \u5e74\u3067\u751f\u5e74\u6708\u65e5\u3092\u5165\u529b\u3059\u308b\u30bb\u30ec\u30af\u30c8\u30dc\u30c3\u30af\u30b9<\/strong>\u3067\u3059\u3002<\/p>\n<p>\u3082\u3061\u308d\u3093\u897f\u66a6\u306a\u3089\u30bb\u30ec\u30af\u30c8\u30dc\u30c3\u30af\u30b9\u3072\u3068\u3064\u3067\u554f\u984c\u306a\u306e\u3067\u3059\u304c\u3001\u3053\u308c\u307e\u3067\u9577\u3044\u9593\u304a\u5ba2\u3055\u3093\u306e\u30c7\u30fc\u30bf\u3092\u548c\u66a6\u3067\u7ba1\u7406\u3057\u3066\u304d\u305f\u95a2\u4fc2\u4e0a\u3001\u5165\u529b\u306f\u548c\u66a6\u306b\u3057\u305f\u3044\u3068\u306e\u3054\u8981\u671b\u3067\u3057\u305f\u3002<\/p>\n<p>\u3068\u3044\u3046\u3053\u3068\u3067\u3001\u4eca\u56de\u306f\u524d\u56de\u306b\u5f15\u304d\u7d9a\u304dVue Componennt\u306e\u8a71\u984c\u3067\u3001\u548c\u66a6 + \u5e74\u3067\u9023\u643a\u3059\u308b\u30bb\u30ec\u30af\u30c8\u30dc\u30c3\u30af\u30b9\u3092\u3064\u304f\u3063\u3066\u307f\u307e\u3059\u3002<\/p>\n<p>\u305c\u3072\u5b66\u7fd2\u306e\u5f79\u306b\u7acb\u3066\u3066\u304f\u3060\u3055\u3044\u306d\u3002\uff08\u6700\u5f8c\u306b\u6559\u6750\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3067\u304d\u307e\u3059\u3002\uff09<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-519 aligncenter\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/05\/21.png\" alt=\"\" width=\"192\" height=\"320\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/05\/21.png 192w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/05\/21-180x300.png 180w\" sizes=\"auto, (max-width: 192px) 100vw, 192px\" \/><\/p>\n<h1>\u3084\u308a\u305f\u3044\u3053\u3068<\/h1>\n<p>\u307e\u305a\u30bb\u30ec\u30af\u30c8\u30dc\u30c3\u30af\u30b9\u306f\u6b21\u306e\uff12\u3064\u3067\u3059\u3002<\/p>\n<ul>\n<li>\u5143\u53f7<\/li>\n<li>\u5e74<\/li>\n<\/ul>\n<p>\u305d\u3057\u3066\u3001\u300c\u5143\u53f7\u300d\u3092\u9078\u629e\u3059\u308b\u3068\u81ea\u52d5\u7684\u306b\u300c\u5e74\u300d\u306e\u4e2d\u8eab\u304c\u5143\u5e74\u301c\u305d\u306e\u5143\u53f7\u306e\u6700\u5927\u5e74\u306b\u5909\u5316\u3059\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/p>\n<p>\u3067\u306f\u3001\u5b9f\u969b\u306b\u958b\u767a\u3092\u9032\u3081\u3066\u3044\u304d\u307e\u3057\u3087\u3046\uff01<\/p>\n<h1>Vue\u306e\u57fa\u672c\u5f62\u3092\u3064\u304f\u308b<\/h1>\n<p>\u3067\u306f\u3001Vue\u304c\u4f7f\u3048\u308b\u3088\u3046\u306b\u57fa\u672c\u5f62\u3092\u4f5c\u308a\u3001\u3053\u3053\u306b\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3092\u3064\u304f\u3063\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<pre>&lt;html&gt;\r\n&lt;body&gt;\r\n    &lt;div <strong>id=\"app\"<\/strong>&gt;\r\n        &lt;!-- \u3053\u3053\u306eVue\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8 --&gt;\r\n    &lt;\/div&gt;\r\n    <strong>&lt;script src=\"https:\/\/cdn.jsdelivr.net\/npm\/vue@2.5.17\/dist\/vue.min.js\"&gt;&lt;\/script&gt;<\/strong>\r\n    &lt;script&gt;\r\n\r\n        new Vue({\r\n            el: <strong>'#app'<\/strong>\r\n        });\r\n\r\n    &lt;\/script&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;<\/pre>\n<p>\u203b Vue\u672c\u4f53\u306f<code>cdn<\/code>\u304b\u3089\u8aad\u307f\u8fbc\u3093\u3067\u3044\u307e\u3059\u3002<\/p>\n<h1>Vue\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3092\u3064\u304f\u308b<\/h1>\n<p>\u4eca\u56de\u306e\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306f\u5143\u53f7\u3068\u5e74\u306e\u30bb\u30ec\u30af\u30c8\u30dc\u30c3\u30af\u30b9\u304c\u5fc5\u8981\u306b\u306a\u308a\u3001\u3055\u3089\u306b\u5404\u30bb\u30ec\u30af\u30c8\u30dc\u30c3\u30af\u30b9\u306b\u69d8\u3005\u306a\u30b3\u30fc\u30c9\u304c\u5fc5\u8981\u306b\u306a\u3063\u3066\u304f\u308b\u306e\u3067\u3001\u69cb\u9020\u306f\u6b21\u306e\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/p>\n<ul>\n<li>v-wareki-input\u3000\u30fb\u30fb\u30fb\u3000\u89aa\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8<\/li>\n<li>v-wareki-gengo-input\u3000\u30fb\u30fb\u30fb\u3000\u5143\u53f7\u306e\u9078\u629e \uff08\u5b50\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8 &#8211; 1\uff09<\/li>\n<li>v-wareki-year-input\u3000\u30fb\u30fb\u30fb\u3000\u5e74\u306e\u9078\u629e \uff08\u5b50\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8 &#8211; 2\uff09<\/li>\n<\/ul>\n<p>\u3064\u307e\u308a\u3001<code>v-wareki-input<\/code>\u3068\u3044\u3046\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306e\u4e2d\u306b\u3001<code>v-wareki-gengo-input<\/code>\u3068<code>v-wareki-year-input<\/code>\u3068\u3044\u3046\uff12\u3064\u306e\u5b50\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u304c\u542b\u307e\u308c\u3066\u3044\u308b\u5f62\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u3067\u306f\u3072\u3068\u3064\u305a\u3064\u958b\u767a\u3057\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<h2>\u5143\u53f7\u3092\u9078\u629e\u3059\u308b\u30bb\u30ec\u30af\u30c8\u30dc\u30c3\u30af\u30b9<\/h2>\n<p>\u307e\u305a\u306f\u6b21\u306e\u3088\u3046\u306b\u5143\u53f7\u3092\u9078\u629e\u3067\u304d\u308b\u30bb\u30ec\u30af\u30c8\u30dc\u30c3\u30af\u30b9\u3092\u81ea\u52d5\u751f\u6210\u3059\u308b\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3067\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1946\" style=\"border: 1px solid #ccc;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/10\/Screenshot-from-2018-10-31-16-26-34.png\" alt=\"\" width=\"64\" height=\"120\" \/><\/p>\n<pre>Vue.component('<strong>v-wareki-gengo-input<\/strong>', {\r\n    props: {\r\n<strong>        value: {<\/strong>\r\n<strong>            type: String,<\/strong>\r\n<strong>            default: 0<\/strong>\r\n<strong>        }<\/strong>\r\n    },\r\n    template:\r\n        '&lt;select v-model=\"value\"&gt;'+\r\n            '&lt;option&gt;&lt;\/option&gt;'+\r\n            <strong>'&lt;option v-for=\"(gengo,index) in $parent.gengoData\" :value=\"index\" v-text=\"gengo.text\"&gt;&lt;\/option&gt;'<\/strong>+\r\n        '&lt;\/div&gt;',\r\n    watch: {\r\n<strong>        value: function(value) {<\/strong>\r\n\r\n<strong>            this.$emit('input', value);<\/strong>\r\n\r\n<strong>        }<\/strong>\r\n    }\r\n\r\n});<\/pre>\n<p>\u3067\u306f\u91cd\u8981\u306a\u90e8\u5206\u3092\u3072\u3068\u3064\u305a\u3064\u307f\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<h3>props<\/h3>\n<p><code>value<\/code>\u306f<code>v-model<\/code>\u306e\u4e2d\u8eab\u304c\u5165\u3063\u3066\u304f\u308b\u5909\u6570\u3067\u3001\u9078\u629e\u4e2d\u3055\u308c\u305f\u5143\u53f7\u306e\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u756a\u53f7\u3067\u3059\u3002\u3064\u307e\u308a\u3001\u5f8c\u3067\u3064\u304f\u308b\u89aa\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u304b\u3089\u6b21\u306e\u3088\u3046\u306b\u5229\u7528\u3057\u307e\u3059\u3002<\/p>\n<pre>&lt;v-wareki-gengo-input <strong>v-model=\"gengoIndex\"<\/strong>&gt;&lt;\/v-wareki-gengo-input&gt;<\/pre>\n<h3>template<\/h3>\n<p>\u91cd\u8981\u306a\u306e\u306f\u3001<code>v-for<\/code>\u3092\u4f7f\u3063\u3066\u5143\u53f7\u306e\u9078\u629e\u80a2\u3092\u4f5c\u3063\u3066\u3044\u308b\u90e8\u5206\u3067\u3059\u3002<br \/>\n\u306a\u304a\u3001<code>$parent.gengoData<\/code>\u306f\u3053\u308c\u304b\u3089\u3064\u304f\u308b\u89aa\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306e\u5909\u6570<code>gengoData<\/code>\u304b\u3089\u30c7\u30fc\u30bf\u3092\u3068\u3063\u3066\u304f\u308b\u3068\u3044\u3046\u610f\u5473\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>v-for=\"(gengo,index) in <strong>$parent.gengoData\"<\/strong><\/pre>\n<h3>watch<\/h3>\n<p><code>value<\/code>\u304c\u5909\u66f4\u3055\u308c\u305f\u3089input\u30a4\u30d9\u30f3\u30c8\u3092\u9001\u51fa\u3057\u307e\u3059\u3002<br \/>\n\u3053\u308c\u306b\u3088\u3063\u3066\u89aa\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306b\u5024\u3092\u4f1d\u3048\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<h2>\u5e74\u3092\u9078\u629e\u3059\u308b\u30bb\u30ec\u30af\u30c8\u30dc\u30c3\u30af\u30b9<\/h2>\n<p>\u7d9a\u3044\u3066\u3001\u5e74\u3092\u9078\u629e\u3059\u308b\u30bb\u30ec\u30af\u30c8\u30dc\u30c3\u30af\u30b9\u3067\u3059\u304c\u3001\u3053\u308c\u306f\u5143\u53f7\u306b\u3088\u3063\u3066\u9078\u629e\u80a2\u304c\u81ea\u52d5\u7684\u306b\u5909\u66f4\u306b\u306a\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3002\uff08\u660e\u6cbb\uff1a 45\u5e74\uff0f\u5927\u6b63\uff1a 15\u5e74\uff0f\u662d\u548c\uff1a 63\u5e74\uff0f\u5e73\u6210\uff1a 30\u5e74\uff09<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1947\" style=\"border: 1px solid #ccc;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/10\/Screenshot-from-2018-10-31-16-42-12.png\" alt=\"\" width=\"67\" height=\"369\" \/><\/p>\n<pre>Vue.component('<strong>v-wareki-year-input<\/strong>', {\r\n    props: {\r\n        <strong>max: {<\/strong>\r\n<strong>            type: Number,<\/strong>\r\n<strong>            default: 0<\/strong>\r\n<strong>        },<\/strong>\r\n<strong>        value: {<\/strong>\r\n<strong>            type: Number,<\/strong>\r\n<strong>            default: 0<\/strong>\r\n<strong>        }<\/strong>\r\n    },\r\n    template:\r\n        '&lt;select v-model=\"value\"&gt;'+\r\n            '&lt;option&gt;&lt;\/option&gt;'+\r\n            '&lt;option <strong>v-for=\"i in max\" :value=\"i\"<\/strong> v-text=\"<strong>year(i)<\/strong>\"&gt;&lt;\/option&gt;'+\r\n        '&lt;\/select&gt;',\r\n    methods: {\r\n        <strong>year: function(i) {<\/strong>\r\n\r\n<strong>            if(i == 1) {<\/strong>\r\n\r\n<strong>                return '\u5143\u5e74';<\/strong>\r\n\r\n<strong>            }<\/strong>\r\n\r\n<strong>            return i +'\u5e74';<\/strong>\r\n\r\n<strong>        }<\/strong>\r\n    },\r\n    watch: {\r\n        <strong>value: function(value) {<\/strong>\r\n\r\n<strong>            this.$emit('input', value);<\/strong>\r\n\r\n<strong>        }<\/strong>\r\n    }\r\n\r\n});<\/pre>\n<p>\u3067\u306f\u3001\u3072\u3068\u3064\u305a\u3064\u307f\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<h3>props<\/h3>\n<p>\u3053\u306e\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306b\u5fc5\u8981\u306a\u30c7\u30fc\u30bf\u306f\u3001<\/p>\n<ul>\n<li>\u9078\u629e\u3057\u305f\u5e74<\/li>\n<li>\u9078\u629e\u3057\u305f\u5143\u53f7\u306b\u5bfe\u5fdc\u3059\u308b\u6700\u5927\u5e74\u6570<\/li>\n<\/ul>\n<p>\u306e\uff12\u3064\u3067\u3059\u3002<\/p>\n<p>\u305d\u306e\u305f\u3081\u3001\u89aa\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u5185\u3067\u306f\u3001\u6b21\u306e\u3088\u3046\u306b\uff12\u3064\u306e\u5909\u6570\u3092\u683c\u7d0d\u3059\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/p>\n<pre>&lt;v-wareki-year-input <strong>:max=\"maxGengoYear\"<\/strong> <strong>v-model=\"gengoYear\"<\/strong>&gt;&lt;\/v-wareki-year-input&gt;<\/pre>\n<p>\u3064\u307e\u308a\u3001<code>maxGengoYear<\/code>\u306f\u5148\u307b\u3069\u306e\u5143\u53f7\u30bb\u30ec\u30af\u30c8\u30dc\u30c3\u30af\u30b9\u304c\u9078\u629e\u3055\u308c\u305f\u3089\u3059\u3050\u81ea\u52d5\u7684\u306b\u5207\u308a\u66ff\u308f\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\uff08\u3053\u308c\u306b\u3064\u3044\u3066\u306f\u89aa\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306e<code>computed<\/code>\u3067\u8aac\u660e\u3057\u307e\u3059\uff09<\/p>\n<h3>template<\/h3>\n<p>\u307e\u305a\u3001<code>v-for<\/code>\u3067\u306f<code>max<\/code>\u3001\u3064\u307e\u308a\u6700\u5927\u5e74\u6570\u5206\u306e\u9078\u629e\u80a2\u3092\u4f5c\u6210\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<pre><strong>v-for=\"i in max\"<\/strong><\/pre>\n<p>\u307e\u305f\u3001\u8868\u793a\u3059\u308b\u30c6\u30ad\u30b9\u30c8\u306f\u300c1\u5e74\u300d\u306e\u5834\u5408\u306f\u300c\u5143\u5e74\u300d\u3068\u3059\u308b\u3079\u304d\u3067\u3059\u306e\u3067\u3001<code>year()<\/code>\u3068\u3044\u3046\u30e1\u30bd\u30c3\u30c9\u3092\u3064\u304f\u308a\u3001\u3053\u306e\u4e2d\u3067\u5024\u304c<code>1<\/code>\u306e\u5834\u5408\u306e\u307f\u300c\u5143\u5e74\u300d\u3092\u8fd4\u3059\u3088\u3046\u306b\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<h3>watch<\/h3>\n<p>\u3053\u306e\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3067\u3082\u3001<code>value<\/code>\u304c\u5909\u66f4\u3055\u308c\u305f\u3089input\u30a4\u30d9\u30f3\u30c8\u3092\u9001\u51fa\u3057\u3001\u89aa\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3078\u5024\u3092\u4f1d\u3048\u3066\u3044\u307e\u3059\u3002<\/p>\n<h2>\u89aa\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8<\/h2>\n<p>\u3067\u306f\u6700\u5f8c\u306b\u89aa\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3067\u3059\u3002<br \/>\n\uff12\u3064\u306e\u5b50\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3092\u9023\u643a\u3055\u305b\u308b\u306e\u3067\u8907\u96d1\u306a\u90e8\u5206\u3082\u3042\u308a\u307e\u3059\u304c\u3001\u3067\u304d\u308b\u3060\u3051\u308f\u304b\u308a\u3084\u3059\u304f\u8aac\u660e\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<pre>Vue.component('<strong>v-wareki-input<\/strong>', {\r\n    props: {\r\n        <strong>value: {<\/strong>\r\n<strong>            type: Number,<\/strong>\r\n<strong>            default: 0<\/strong>\r\n<strong>        }<\/strong>\r\n    },\r\n    template: '&lt;span&gt;'+\r\n                '&lt;v-wareki-gengo-input <strong>v-model=\"gengoIndex\"<\/strong>&gt;&lt;\/v-wareki-gengo-input&gt;&amp;nbsp;'+\r\n                '&lt;v-wareki-year-input <strong>:max=\"maxGengoYear\"<\/strong> <strong>v-model=\"gengoYear\"<\/strong>&gt;&lt;\/v-wareki-year-input&gt;&amp;nbsp;'+\r\n                '&lt;\/span&gt;',\r\n    data: function() {\r\n        return {\r\n            <strong>gengoIndex: '',<\/strong>\r\n<strong>            gengoYear: 0,<\/strong>\r\n<strong>            gengoData: [<\/strong>\r\n<strong>                {text: '\u660e\u6cbb', base: 1867, max: 45},<\/strong>\r\n<strong>                {text: '\u5927\u6b63', base: 1911, max: 15},<\/strong>\r\n<strong>                {text: '\u662d\u548c', base: 1925, max: 63},<\/strong>\r\n<strong>                {text: '\u5e73\u6210', base: 1988, max: 30},<\/strong>\r\n<strong>            ],<\/strong>\r\n<strong>            initialized: false<\/strong>\r\n        }\r\n    },\r\n    methods: {\r\n        <strong>calcYear: function() {<\/strong>\r\n\r\n<strong>            var year = null;<\/strong>\r\n\r\n<strong>            if(this.hasGengo &amp;&amp; this.gengoYear &gt; 0) {<\/strong>\r\n\r\n<strong>                var gengo = this.gengoData[this.gengoIndex];<\/strong>\r\n<strong>                year = this.gengoYear + gengo.base;<\/strong>\r\n\r\n<strong>            }<\/strong>\r\n\r\n<strong>            this.$emit('input', year);<\/strong>\r\n\r\n<strong>        }<\/strong>\r\n    },\r\n    computed: {\r\n        <strong>hasGengo: function() {<\/strong>\r\n\r\n<strong>            return (this.gengoData[this.gengoIndex] != undefined);<\/strong>\r\n\r\n<strong>        },<\/strong>\r\n<strong>        selectingGengo: function() {<\/strong>\r\n\r\n<strong>            return (this.hasGengo)<\/strong>\r\n<strong>                ? this.gengoData[this.gengoIndex]<\/strong>\r\n<strong>                : null;<\/strong>\r\n\r\n<strong>        },<\/strong>\r\n<strong>        maxGengoYear: function() {<\/strong>\r\n\r\n<strong>            return (this.hasGengo)<\/strong>\r\n<strong>                ? this.selectingGengo.max<\/strong>\r\n<strong>                : 0;<\/strong>\r\n\r\n<strong>        }<\/strong>\r\n    },\r\n    mounted: function() {\r\n\r\n        <strong>if(this.value &gt; 0) {<\/strong>\r\n\r\n<strong>            for(var i in this.gengoData) {<\/strong>\r\n\r\n<strong>                var gengo = this.gengoData[i];<\/strong>\r\n\r\n<strong>                if(this.value &gt; gengo.base) {<\/strong>\r\n\r\n<strong>                    this.gengoIndex = i;<\/strong>\r\n<strong>                    this.gengoYear = this.value - gengo.base;<\/strong>\r\n\r\n<strong>                }<\/strong>\r\n\r\n<strong>            }<\/strong>\r\n\r\n<strong>        }<\/strong>\r\n\r\n<strong>        var self = this;<\/strong>\r\n\r\n<strong>        Vue.nextTick(function(){<\/strong>\r\n\r\n<strong>            self.initialized = true;<\/strong>\r\n\r\n<strong>        });<\/strong>\r\n\r\n    },\r\n    watch: {\r\n        <strong>gengoIndex: function() {<\/strong>\r\n\r\n<strong>            if(this.initialized &amp;&amp; this.hasGengo) {<\/strong>\r\n\r\n<strong>                this.gengoYear = 0;<\/strong>\r\n\r\n<strong>            }<\/strong>\r\n\r\n<strong>            this.calcYear();<\/strong>\r\n\r\n<strong>        },<\/strong>\r\n<strong>        gengoYear: function() {<\/strong>\r\n\r\n<strong>            this.calcYear();<\/strong>\r\n\r\n<strong>        }<\/strong>\r\n    }\r\n});<\/pre>\n<p>\u3067\u306f\u3001\u3072\u3068\u3064\u305a\u3064\u898b\u3066\u3044\u304d\u307e\u3059\u3002\uff08\u308f\u304b\u308a\u3084\u3059\u304f\u8aac\u660e\u3057\u305f\u3044\u306e\u3067\u9806\u4e0d\u540c\u3067\u3059\uff09<\/p>\n<h3>props<\/h3>\n<p>value\u306f<code>v-model<\/code>\u306b\u5bfe\u5fdc\u3059\u308b\u90e8\u5206\u3067\u3059\u3002<br \/>\n\u4f8b\u3048\u3070\u3001\u6b21\u306e\u3088\u3046\u306b\u521d\u671f\u5024\u3092\u897f\u66a6\u3067\u5165\u529b\u3059\u308b\u3068\u3001\u81ea\u52d5\u7684\u306b\u548c\u66a6\u306b\u5909\u63db\u3059\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/p>\n<pre>&lt;v-wareki-input <strong>v-model=\"2000\"<\/strong>&gt;&lt;\/v-wareki-input&gt;<\/pre>\n<h3>data<\/h3>\n<p>\u5909\u6570\u306f\u6b21\u306e\u3068\u304a\u308a\u3067\u3059\u3002<\/p>\n<ul>\n<li>gengoIndex\u3000\u30fb\u30fb\u30fb\u3000\u9078\u629e\u3055\u308c\u305f\u5143\u53f7\u306e\u30a4\u30f3\u30c7\u30c3\u30af\u30b9<\/li>\n<li>gengoYear\u3000\u30fb\u30fb\u30fb\u3000\u9078\u629e\u3055\u308c\u305f\u5e74<\/li>\n<li>gengoData\u3000\u30fb\u30fb\u30fb\u3000\u5143\u53f7\u306e\u30de\u30b9\u30bf\u30fc\u30c7\u30fc\u30bf\u3002\u3053\u3053\u3067\u4e00\u5143\u7ba1\u7406\u3057\u305f\u3044\u306e\u3067\u3001\u5b50\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u304b\u3089\u306f$parent\u3068\u3057\u3066\u547c\u3073\u51fa\u3057\u3066\u3044\u307e\u3059\u3002\u3082\u3057\u65b0\u5143\u53f7\u306b\u306a\u3063\u305f\u3089\u3053\u3053\u306b\u30c7\u30fc\u30bf\u3092\u8ffd\u52a0\u3059\u308b\u3060\u3051\u3067OK\u3067\u3059\u3002<\/li>\n<li>initialized\u3000\u30fb\u30fb\u30fb\u3000\u30da\u30fc\u30b8\u8868\u793a\u3055\u308c\u3066\u3059\u3050\u304b\u3069\u3046\u304b\u304b\u304c\u5206\u304b\u308b\u5909\u6570\u3002<code>true<\/code> or <code>false<\/code><\/li>\n<\/ul>\n<p>\u203b \u306a\u304a\u3001Vue\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306f\u95a2\u6570\u306e\u8fd4\u308a\u5024\u3068\u3057\u3066\u8a2d\u5b9a\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\u305d\u306e\u305f\u3081\u3001<code>function<\/code>\u3092\u4f7f\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<h3>computed<\/h3>\n<p><code>computed<\/code>\u306e\u5185\u5bb9\u306f\u6b21\u306e\u3068\u304a\u308a\u3067\u3059\u3002<\/p>\n<ul>\n<li>hasGengo()\u3000\u30fb\u30fb\u30fb\u3000\u5143\u53f7\u304c\u9078\u629e\u3055\u308c\u3066\u3044\u308b\u304b\u3069\u3046\u304b\u3002<code>true<\/code> or <code>false<\/code><\/li>\n<li>selectingGengo()\u3000\u30fb\u30fb\u30fb\u3000\u73fe\u5728\u9078\u629e\u3055\u308c\u3066\u3044\u308b\u5143\u53f7\uff08\u3060\u3051\uff09\u306e\u30c7\u30fc\u30bf<\/li>\n<li>maxGengoYear()\u3000\u30fb\u30fb\u30fb\u3000\u73fe\u5728\u9078\u629e\u3055\u308c\u3066\u3044\u308b\u5143\u53f7\u306e\u6700\u5927\u5e74\u6570<\/li>\n<\/ul>\n<h3>template<\/h3>\n<p>\uff12\u3064\u306e\u3053\u306e\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3092\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3068\u3057\u3066\u547c\u3073\u51fa\u3057\u3001\u305d\u308c\u305e\u308c\u5909\u6570<code>gengoIndex<\/code>\u3068<code>gengoYear<\/code>\u3092\u30d0\u30a4\u30f3\u30c7\u30a3\u30f3\u30b0\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u91cd\u8981\u306a\u306e\u306f\u3001<code>maxGengoYear<\/code>\u306e\u90e8\u5206\u3067\u3001\u3053\u308c\u306f<code>computed<\/code>\u306e<code>maxGengoYear()<\/code>\u306e\u7d50\u679c\u304c\u81ea\u52d5\u7684\u306b\u5165\u308b\u3088\u3046\u306b\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<h3>methods<\/h3>\n<p><code>calcYear()<\/code>\u306f\u3001\u5143\u53f7\u3068\u5e74\u306e\u4e21\u65b9\u304c\u9078\u629e\u3055\u308c\u305f\u72b6\u614b\u306a\u3089\u3001\u305d\u308c\u304c\u897f\u66a6\u4f55\u5e74\u304b\u3092\u8a08\u7b97\u3057\u3001\u7d50\u679c\u3092<code>$emit<\/code>\u3067\u547c\u3073\u51fa\u3057\u5143\u306b\u4f1d\u3048\u3066\u3044\u307e\u3059\u3002\u3064\u307e\u308a\u3001\u6b21\u306e\u5834\u5408\u3001\u5909\u6570<code>year<\/code>\u304c\u81ea\u52d5\u7684\u306b\u66f4\u65b0\u3055\u308c\u307e\u3059\u3002<\/p>\n<pre>&lt;v-wareki-input <strong>v-model=\"year\"<\/strong>&gt;&lt;\/v-wareki-input&gt;<\/pre>\n<p>\u203b \u306a\u304a\u3001\u3082\u3057\u5143\u53f7\u3084\u5e74\u304c\u9078\u629e\u3055\u308c\u3066\u3044\u306a\u3044\u3068\u304d\u306f<code>null<\/code>\u3092\u8fd4\u3059\u3088\u3046\u306b\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<h3>mounted<\/h3>\n<p><code>value<\/code>\uff08\u897f\u66a6\uff09\u306b\u521d\u671f\u5024\u304c\u5165\u3063\u3066\u3044\u305f\u3089\u3001\u8a08\u7b97\u3057\u3066\u5143\u53f7\u3068\u5e74\u3092\u30bb\u30c3\u30c8\u3059\u308b\u3088\u3046\u306b\u3057\u3066\u3044\u307e\u3059\u3002\u307e\u305f\u3001\u6700\u5f8c\u306b<code>initialized<\/code>\u3092<code>true<\/code>\u306b\u5909\u66f4\u3057\u3066\u3044\u307e\u3059\u3002\uff08\u3053\u306e\u90e8\u5206\u306f\u8a73\u3057\u304f<code>watch<\/code>\u3067\u8aac\u660e\u3057\u307e\u3059\uff09<\/p>\n<h3>watchs<\/h3>\n<p>\u5909\u6570<code>gengoIndex<\/code>\u3068<code>gengoYear<\/code>\u306b\u5909\u66f4\u304c\u3042\u3063\u305f\u3089<code>calcYear()<\/code>\u3067\u897f\u66a6\u3092\u8a08\u7b97\u3059\u308b\u3088\u3046\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u305d\u3057\u3066\u3001\u3053\u3053\u3067\u91cd\u8981\u306a\u306e\u304c<code>gengoIndex<\/code>\u306e\u6b21\u306e\u90e8\u5206\u3067\u3059\u3002<\/p>\n<pre>if(<strong>this.initialized<\/strong> &amp;&amp; this.hasGengo) {\r\n\r\n    this.gengoYear = 0;\r\n\r\n}<\/pre>\n<p>\u306a\u305c\u30da\u30fc\u30b8\u304c\u8868\u793a\u3055\u308c\u3066\u3059\u3050\u306e\u5834\u5408\u306f<code>gengoYear<\/code>\u3092<code>0<\/code>\u306b\u306f\u3057\u306a\u3044\u304b\u3068\u3044\u3046\u3068\u3001\u4f8b\u3048\u3070\u3001\u521d\u671f\u5024\u3092<code>2000<\/code>\u306b\u3057\u305f\u5834\u5408\u3001<code>mounted<\/code>\u306e\u4e2d\u3067<\/p>\n<ul>\n<li>\u5143\u53f7\u3000\u30fb\u30fb\u30fb\u3000\u5e73\u6210<\/li>\n<li>\u5e74\u3000\u30fb\u30fb\u30fb\u300012<\/li>\n<\/ul>\n<p>\u3068\u548c\u66a6\u3078\u306e\u5909\u63db\u304c\u884c\u308f\u308c\u307e\u3059\u3002\u305d\u3057\u3066\u3001\u305d\u308c\u305e\u308c<code>gengoIndex<\/code>\u3068<code>gengoYear<\/code>\u306b\u305d\u306e\u5024\u304c\u683c\u7d0d\u3055\u308c\u308b\u3053\u3068\u306b\u306a\u308b\u306e\u3067\u3059\u304c\u3001\u3082\u3057<code>initialized<\/code>\u3067\u5b88\u3063\u3066\u3044\u306a\u3044\u3068<code>gengoIndex<\/code>\u3092\u5909\u66f4\u3057\u305f\u6642\u70b9\u3067\u3001<code>watch<\/code>\u306b\u3088\u3063\u3066<code>12<\/code>\u304c<code>0<\/code>\u306b\u4e0a\u66f8\u304d\u3055\u308c\u3066\u3057\u307e\u3046\u306e\u3067\u3059\u3002<\/p>\n<p><code>mounted<\/code>\u5185\u3067<code>nextTick()<\/code>\u3092\u4f7f\u3063\u3066\u3044\u308b\u306e\u3082\u305d\u306e\u305f\u3081\u3067\u3059\u3002<\/p>\n<pre>var self = this;\r\n\r\n<strong>Vue.nextTick(function(){<\/strong>\r\n\r\n<strong>    self.initialized = true;<\/strong>\r\n\r\n<strong>});<\/strong><\/pre>\n<p><code>nextTick()<\/code>\u306f\u4e00\u65e6\u30ec\u30f3\u30c0\u30ea\u30f3\u30b0\u304c\u5b8c\u4e86\u3057\u3066\u304b\u3089\u4e2d\u8eab\u3092\u5b9f\u884c\u3059\u308b\u306e\u3067\u3059\u304c\u3001\u3053\u3046\u3057\u306a\u3044\u3068\u540c\u3058\u304f\u30bf\u30a4\u30df\u30f3\u30b0\u7684\u306b<code>gengoYear<\/code>\u306f<code>0<\/code>\u306b\u4e0a\u66f8\u304d\u3055\u308c\u3066\u3057\u307e\u3044\u307e\u3059\u3002<\/p>\n<h1>\u30c7\u30e2\u3092\u7528\u610f\u3057\u307e\u3057\u305f<\/h1>\n<p>\u5b9f\u969b\u306e\u30ad\u30e3\u30d7\u30c1\u30e3\u753b\u50cf\u306f\u6b21\u306e\u3068\u304a\u308a\u3067\u3059\u304c\u3001\u753b\u50cf\u3060\u3051\u3067\u306f\u5206\u304b\u308a\u306b\u304f\u3044\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u306e\u3067\u3001\u5b9f\u969b\u306b\u4f53\u9a13\u3067\u304d\u308b<a href=\"https:\/\/demo-laravel52.capilano-fw.com\/vue_wareki\" target=\"_blank\" rel=\"noopener\">\u30c7\u30e2\u30da\u30fc\u30b8<\/a>\u3092\u7528\u610f\u3057\u307e\u3057\u305f\u3002\u305c\u3072\u89e6\u3063\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1948\" style=\"border: 1px solid #ccc;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/10\/vue_wareki_input_1.png\" alt=\"\" width=\"139\" height=\"240\" \/><\/p>\n<h1>\u6559\u6750\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3059\u308b<\/h1>\n<p>\u4eca\u56de\u958b\u767a\u3057\u305f\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u4e00\u5f0f\uff08Vue Component\u3092\u542b\u3080\uff09\u3092\u4ee5\u4e0b\u304b\u3089\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3067\u304d\u307e\u3059\u3002<code>cdn<\/code>\u3067<code>Vue<\/code>\u3092\u8aad\u307f\u8fbc\u3093\u3067\u3044\u308b\u306e\u3067\u5c55\u958b\u3057\u3066\u3059\u3050\u5b9f\u884c\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<a  data-e-Disable-Page-Transition=\"true\" class=\"download-link\" title=\"\" href=\"https:\/\/blog.capilano-fw.com?download=1949&amp;tmstv=1777530163\" rel=\"nofollow\" id=\"download-link-1949\" data-redirect=\"false\" >\n\t\u548c\u66a6\u3092\u5165\u529b\u3059\u308bVue Component\uff1a \u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u4e00\u5f0f<\/a>\n\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3055\u3066\u3055\u3066\u3001\u524d\u56de\u306e\u8a18\u4e8b\u300cVue Component \u3067\uff12\u679a\u306e\u753b\u50cf\u3092\u5207\u308a\u66ff\u3048\u308b\u30c1\u30a7\u30c3\u30af\u30dc\u30c3\u30af\u30b9\u3092\u3064\u304f\u3063\u3066\u307f\u3088\u3046\u300d\u3067\u306f\u72ec\u81ea\u306e\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\uff08\u2252\u7591\u4f3cHTML\u30bf\u30b0\uff09\u3092\u4f5c\u3063 &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/blog.capilano-fw.com\/?p=1943\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;Vue Component \u3067\u548c\u66a6\u304b\u3089\u897f\u66a6\u306b\u5909\u63db\u3059\u308b\u30bb\u30ec\u30af\u30c8\u30dc\u30c3\u30af\u30b9\u3092\u3064\u304f\u308b&#8221; \u306e<\/span>\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":1954,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19,12],"tags":[101,102],"class_list":["post-1943","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-javascript","category-vue-js","tag-vue-component","tag-102"],"_links":{"self":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/1943","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1943"}],"version-history":[{"count":3,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/1943\/revisions"}],"predecessor-version":[{"id":1955,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/1943\/revisions\/1955"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/media\/1954"}],"wp:attachment":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1943"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1943"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1943"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}