{"id":2302,"date":"2018-11-15T03:35:01","date_gmt":"2018-11-14T18:35:01","guid":{"rendered":"https:\/\/blog.capilano-fw.com\/?p=2302"},"modified":"2018-11-15T03:35:01","modified_gmt":"2018-11-14T18:35:01","slug":"%e6%84%8f%e5%a4%96%e3%81%a8%e7%b0%a1%e5%8d%98%ef%bc%81vuejs%e3%81%a7%e5%8f%8d%e5%b0%84%e7%a5%9e%e7%b5%8c%e3%82%b2%e3%83%bc%e3%83%a0%e3%82%92%e3%81%a4%e3%81%8f%e3%81%a3%e3%81%a6%e3%81%bf%e3%82%88","status":"publish","type":"post","link":"https:\/\/blog.capilano-fw.com\/?p=2302","title":{"rendered":"\u610f\u5916\u3068\u7c21\u5358\uff01VueJS\u3067\u53cd\u5c04\u795e\u7d4c\u30b2\u30fc\u30e0\u3092\u3064\u304f\u3063\u3066\u307f\u3088\u3046\uff08\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u53ef\uff09"},"content":{"rendered":"<p>\u3055\u3066\u3055\u3066\u3001\u3053\u306e\u3068\u3053\u308d<code>Electron<\/code>\u958b\u767a\u304c\u697d\u3057\u3044\u306e\u3067\u305d\u3061\u3089\u95a2\u9023\u306e\u8a18\u4e8b\u304c\u591a\u304f\u306a\u3063\u3066\u3044\u307e\u3059\u304c\u3001\u3084\u306f\u308a\u305f\u307e\u306b\u306f\u305d\u306e\u4ed6\u306e\u8a71\u984c\u3082\u3001\u3068\u3044\u3046\u3053\u3068\u3067\u4eca\u56de\u306fVue.js\u3092\u4f7f\u3063\u305f\u958b\u767a\u306e\u3054\u7d39\u4ecb\u3067\u3059\u3002<\/p>\n<p><strong>\u30c6\u30fc\u30de\u306f\u3001\u300c\u53cd\u5c04\u795e\u7d4c\u30b2\u30fc\u30e0\u300d\u3067\u3059\u3002<\/strong><\/p>\n<p>\u3068\u3044\u3046\u306e\u3082\u3001\u3053\u306e\u30d6\u30ed\u30b0\u3067\u306f\u3067\u304d\u308b\u3060\u3051\u30d3\u30ae\u30ca\u30fc\u306e\u65b9\u306b\u3082\u308f\u304b\u308a\u3084\u3059\u304f\u3001\u8208\u5473\u3092\u3082\u3066\u308b\u8a71\u984c\u3092\u63d0\u4f9b\u3057\u305f\u3044\u306e\u3067\u3001\u4eca\u56de\u306f\u3044\u3064\u3082\u306e\u3088\u3046\u306a\u696d\u52d9\u611f\u3092\u306a\u304f\u3057\u3066\u30b2\u30fc\u30e0\u306e\u3064\u304f\u308a\u65b9\u3092\u8a18\u4e8b\u306b\u3057\u3066\u307f\u307e\u3059\u3002<\/p>\n<p>\u3067\u306f\u3001\u4eca\u56de\u3082\u6700\u5f8c\u306b\u6559\u6750\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u3092\u7528\u610f\u3057\u307e\u3057\u305f\u306e\u3067\u3001\u305c\u3072\u30b9\u30ad\u30eb\u30a2\u30c3\u30d7\u306b\u5f79\u7acb\u3066\u3066\u304f\u3060\u3055\u3044\u306d\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-418 aligncenter\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/04\/35.png\" alt=\"\" width=\"370\" height=\"240\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/04\/35.png 370w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/04\/35-300x195.png 300w\" sizes=\"auto, (max-width: 370px) 100vw, 370px\" \/><\/p>\n<p>\u958b\u767a\u74b0\u5883\uff1a Vue 2.5\u3001Google Chrome 70<\/p>\n<h1>\u3084\u308a\u305f\u3044\u3053\u3068<\/h1>\n<p>\u307e\u305a\u4e38\u3044\u5f62\u3092\u3057\u305f\u30dc\u30bf\u30f3\u309225\u500b\u7528\u610f\u3057\u307e\u3059\u3002<\/p>\n<p>\u305d\u306e\u30dc\u30bf\u30f3\u306f\u30e9\u30f3\u30c0\u30e0\u3067\uff11\u500b\u3060\u3051\u8272\u304c\u5909\u308f\u308b\u306e\u3067\u6311\u6226\u8005\u306f\u3053\u306e\u8d64\u4e38\u3092\u30af\u30ea\u30c3\u30af\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<p>\u305d\u3057\u3066\u3001\u8d64\u4e38\u3092\uff11\uff10\u500b\u30af\u30ea\u30c3\u30af\u3059\u308b\u3068\u30b2\u30fc\u30e0\u7d42\u4e86\u3002\u8981\u3059\u308b\u306b\u6700\u77ed\u6642\u9593\u3092\u76ee\u6307\u3059\u30b2\u30fc\u30e0\u3067\u3059\u3002\uff08\u3061\u306a\u307f\u306b\u9593\u9055\u3063\u305f\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3057\u305f\u5834\u5408\u306f+10\u79d2\u30da\u30ca\u30eb\u30c6\u30a3\u3092\u52a0\u7b97\u3057\u307e\u3059\uff09<\/p>\n<h1>\u30ec\u30a4\u30a2\u30a6\u30c8\u3092\u3064\u304f\u308b<\/h1>\n<p>\u3067\u306f\u3001\u307e\u305a\u306f\u30ec\u30a4\u30a2\u30a6\u30c8\u3092\u3064\u304f\u308a\u307e\u3057\u3087\u3046\u3002<br \/>\n\u5b9f\u969b\u306eHTML\u30b3\u30fc\u30c9\u3067\u3059\u3002<\/p>\n<pre>&lt;html&gt;\r\n&lt;head&gt;\r\n    <strong>&lt;link href=\"https:\/\/stackpath.bootstrapcdn.com\/bootstrap\/4.1.3\/css\/bootstrap.min.css\" rel=\"stylesheet\"&gt;<\/strong>\r\n    &lt;style&gt;\r\n\r\n        body {\r\n            padding: 15px;\r\n        }\r\n\r\n        .circle-button {\r\n            margin: 10px;\r\n            text-align: center;\r\n            vertical-align: middle;\r\n            height: 75px;\r\n            width: 75px;\r\n            border-radius: 50%;\r\n            color: #999999;\r\n            border: 4px solid #CCCCCC;\r\n            background: #fff;\r\n            outline: none !important;\r\n        }\r\n\r\n        .current-button {\r\n            color: #f44336;\r\n            border: 4px solid #f44336;\r\n        }\r\n\r\n    &lt;\/style&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n    &lt;div id=\"app\"&gt;\r\n        &lt;h1&gt;Vue\u3067\u53cd\u5c04\u795e\u7d4c\u30b2\u30fc\u30e0\uff01&lt;\/h1&gt;\r\n        &lt;hr&gt;\r\n        &lt;button class=\"circle-button\"&gt;&lt;\/button&gt;\r\n        &lt;button class=\"circle-button\"&gt;&lt;\/button&gt;\r\n        &lt;button class=\"circle-button\"&gt;&lt;\/button&gt;\r\n        &lt;button class=\"circle-button\"&gt;&lt;\/button&gt;\r\n        &lt;button class=\"circle-button\"&gt;&lt;\/button&gt;\r\n        &lt;br&gt;\r\n        &lt;button class=\"circle-button\"&gt;&lt;\/button&gt;\r\n        &lt;button class=\"circle-button\"&gt;&lt;\/button&gt;\r\n        &lt;button class=\"circle-button\"&gt;&lt;\/button&gt;\r\n        &lt;button class=\"circle-button\"&gt;&lt;\/button&gt;\r\n        &lt;button class=\"circle-button\"&gt;&lt;\/button&gt;\r\n        &lt;br&gt;\r\n        &lt;button class=\"circle-button\"&gt;&lt;\/button&gt;\r\n        &lt;button class=\"circle-button current-button\"&gt;&lt;\/button&gt;\r\n        &lt;button class=\"circle-button\"&gt;&lt;\/button&gt;\r\n        &lt;button class=\"circle-button\"&gt;&lt;\/button&gt;\r\n        &lt;button class=\"circle-button\"&gt;&lt;\/button&gt;\r\n        &lt;br&gt;\r\n        &lt;button class=\"circle-button\"&gt;&lt;\/button&gt;\r\n        &lt;button class=\"circle-button\"&gt;&lt;\/button&gt;\r\n        &lt;button class=\"circle-button\"&gt;&lt;\/button&gt;\r\n        &lt;button class=\"circle-button\"&gt;&lt;\/button&gt;\r\n        &lt;button class=\"circle-button\"&gt;&lt;\/button&gt;\r\n        &lt;br&gt;\r\n        &lt;button class=\"circle-button\"&gt;&lt;\/button&gt;\r\n        &lt;button class=\"circle-button\"&gt;&lt;\/button&gt;\r\n        &lt;button class=\"circle-button\"&gt;&lt;\/button&gt;\r\n        &lt;button class=\"circle-button\"&gt;&lt;\/button&gt;\r\n        &lt;button class=\"circle-button\"&gt;&lt;\/button&gt;\r\n        &lt;br&gt;\r\n        &lt;br&gt;\r\n        &lt;h4&gt;00:00:00 \u79d2&lt;\/h4&gt;\r\n        &lt;button class=\"btn btn-lg btn-dark\"&gt;\u30b9\u30bf\u30fc\u30c8&lt;\/button&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: '#app'\r\n        });\r\n\r\n    &lt;\/script&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;<\/pre>\n<p>\u3053\u308c\u3092\u5b9f\u884c\u3057\u305f\u3082\u306e\u304c\u3053\u3061\u3089\u3067\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2305\" style=\"border: 1px solid #ccc;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/11\/vue_reflexes_1.png\" alt=\"\" width=\"534\" height=\"699\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/11\/vue_reflexes_1.png 534w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/11\/vue_reflexes_1-229x300.png 229w\" sizes=\"auto, (max-width: 534px) 100vw, 534px\" \/><\/p>\n<p>\u3067\u306f\u3001\u3053\u306e\u30ec\u30a4\u30a2\u30a6\u30c8\u3092\u4f7f\u3063\u3066JavaScript\u306e\u30b3\u30fc\u30c9\u3092\u66f8\u3044\u3066\u3044\u304d\u307e\u3057\u3087\u3046\uff01<\/p>\n<h1>JavaScript\u306e\u30b3\u30fc\u30c9\u3092\u3064\u304f\u308b<\/h1>\n<h2>\u4e38\u30dc\u30bf\u30f3\u90e8\u5206\u3092\u3064\u304f\u308b<\/h2>\n<p>\u307e\u305a\u306f\u4e38\u30dc\u30bf\u30f3\u3092vue\u3067\u8868\u793a\u3059\u308b\u90e8\u5206\u3092\u4f5c\u3063\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<pre>&lt;span <strong>v-for=\"buttonNumber in 25\"<\/strong>&gt;\r\n    &lt;button class=\"circle-button\" <strong>@click=\"onClick()\"<\/strong>&gt;&lt;\/button&gt;\r\n    &lt;br <strong>v-if=\"buttonNumber%5 == 0\"<\/strong>&gt;\r\n&lt;\/span&gt;<\/pre>\n<p>\u4f7f\u3046\u306e\u306f<code>v-for<\/code>\u3067\u3059\u3002<code>v-for<\/code>\u306f\u914d\u5217\u3084\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u30eb\u30fc\u30d7\u306b\u3088\u304f\u4f7f\u308f\u308c\u307e\u3059\u304c\u3001\u3053\u306e\u3088\u3046\u306b\u6570\u5b57\u3067\u3082\u5229\u7528\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\uff08\u305f\u3060\u3057\u3001\u6570\u5b57\u306f<code>0<\/code>\u3067\u306f\u306a\u304f<code>1<\/code>\u304b\u3089\u59cb\u307e\u308a\u307e\u3059\uff09<\/p>\n<p>\u307e\u305f\u3001<code>v-if<\/code>\u3092\u4f7f\u3063\u3066\u3001<code>buttonNumber\u00f7\uff15<\/code>\u304c\u30bc\u30ed\u306b\u306a\u308b\u3001\u3064\u307e\u308a\uff15\u306e\u500d\u6570\u306e\u3068\u304d\u3060\u3051<code>&lt;br&gt;<\/code>\u3067\u958b\u696d\u3059\u308b\u3088\u3046\u306b\u3057\u3066\u3044\u307e\u3059\u3002\u305d\u306e\u305f\u3081\u3001\u30dc\u30bf\u30f3\u304c\uff15\u3064\u305a\u3064\u4e0a\u304b\u3089\u306a\u3089\u3093\u3067\uff15\u5217\u3001\u5408\u8a08\uff12\uff15\u500b\u306e\u30dc\u30bf\u30f3\u304c\u4f5c\u6210\u3055\u308c\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u5b9f\u969b\u306b\u5b9f\u884c\u3057\u305f\u3082\u306e\u304c\u3053\u3061\u3089\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2306\" style=\"border: 1px solid #ccc;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/11\/vue_reflexes_2.png\" alt=\"\" width=\"541\" height=\"566\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/11\/vue_reflexes_2.png 541w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/11\/vue_reflexes_2-287x300.png 287w\" sizes=\"auto, (max-width: 541px) 100vw, 541px\" \/><\/p>\n<p>\u203b \u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3057\u305f\u3068\u304d\u306e\u6319\u52d5\u306f\u5f8c\u3067\u3064\u304f\u308a\u307e\u3059\u3002<\/p>\n<h2>\u7d4c\u904e\u6642\u9593\u306e\u90e8\u5206\u3092\u3064\u304f\u308b<\/h2>\n<p>\u307e\u305a\u306f\u3001\u7d4c\u904e\u6642\u9593\uff08\u79d2\uff09\u3092\u683c\u7d0d\u3059\u308b\u5909\u6570<code>seconds<\/code>\u3092\u767b\u9332\u3057\u307e\u3059\u3002<\/p>\n<p>\u305d\u3057\u3066\u3001\u30ad\u30e3\u30c3\u30b7\u30e5\u304c\u304d\u304f<code>computed<\/code>\u306b<code>secondsInHMS<\/code>\u3068\u3044\u3046\u540d\u524d\u306e\u79d2\u3092\u300c\u6642\uff1a\u5206\uff1a\u79d2\u300d\u8868\u8a18\u306b\u5909\u63db\u3059\u308b\u7591\u4f3c\u5909\u6570\u3092\u3064\u304f\u308a\u307e\u3059\u3002<\/p>\n<pre>methods: {\r\n    <strong>strPad(number) {<\/strong>\r\n\r\n<strong>        let str = number.toString();<\/strong>\r\n\r\n<strong>        if(str.toString().length == 1) {<\/strong>\r\n\r\n<strong>            str = '0'+ str;<\/strong>\r\n\r\n<strong>        }<\/strong>\r\n\r\n<strong>        return str;<\/strong>\r\n\r\n<strong>    }<\/strong>\r\n},\r\ncomputed: {\r\n    <strong>secondsInHMS() {<\/strong>\r\n\r\n<strong>        const hours = Math.floor(this.seconds \/ 3600);<\/strong>\r\n<strong>        const minutes = Math.floor(this.seconds % 3600 \/ 60);<\/strong>\r\n<strong>        const seconds = Math.floor(this.seconds % 3600 % 60);<\/strong>\r\n<strong>        return this.strPad(hours) +':'<\/strong>\r\n<strong>                + this.strPad(minutes) +':'<\/strong>\r\n<strong>                + this.strPad(seconds)<\/strong>\r\n\r\n<strong>    }<\/strong>\r\n}<\/pre>\n<p>\u306a\u304a\u3001\u6570\u5b57\u304c\u3072\u3068\u6841\u306e\u5834\u5408\u306f\u30bc\u30ed\u3092\u8db3\u3057\u3066\u300c05\u300d\u3068\u3057\u305f\u3044\u306e\u3067<code>methods<\/code>\u306b<code>strPad()<\/code>\u3082\u8ffd\u52a0\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u3067\u306f\u3001HTML\u3078\u8a2d\u7f6e\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre>&lt;h4&gt;<strong>{{ secondsInHMS }}<\/strong> \u79d2&lt;\/h4&gt;<\/pre>\n<p>\u305d\u3057\u3066\u3001\u30c6\u30b9\u30c8\u30674000\u79d2\u7d4c\u904e\u3057\u305f\u3082\u306e\u3068\u3057\u3066\u5b9f\u884c\u3057\u305f\u3082\u306e\u304c\u3053\u3061\u3089\u3067\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2307\" style=\"border: 1px solid #ccc;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/11\/vue_reflexes_3.png\" alt=\"\" width=\"147\" height=\"105\" \/><\/p>\n<h2>\u30b9\u30bf\u30fc\u30c8\u30dc\u30bf\u30f3\u3092\u3064\u304f\u308b<\/h2>\n<p>\u3067\u306f\u3001\u30b9\u30bf\u30fc\u30c8\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3057\u305f\u6642\u306e\u30b3\u30fc\u30c9\u3092\u3064\u304f\u308a\u307e\u3059\u3002<\/p>\n<p>\u307e\u305a\u306f\u6642\u9593\u306e\u30bf\u30a4\u30de\u30fc\u304c\u683c\u7d0d\u3055\u308c\u308b\u5909\u6570<code>timer<\/code>\u3092\u767b\u9332\u3002<\/p>\n<pre>data: {\r\n    seconds: 0,\r\n    <strong>timer: null<\/strong>\r\n},<\/pre>\n<p>\u305d\u3057\u3066\u3001<code>@click<\/code>\u3067<code>start()<\/code>\u304c\u5b9f\u884c\u3055\u308c\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/p>\n<pre>&lt;button class=\"btn btn-lg btn-dark\" <strong>@click=\"start()\"<\/strong>&gt;\u30b9\u30bf\u30fc\u30c8&lt;\/button&gt;<\/pre>\n<p><strong>start()<\/strong>\u306e\u4e2d\u8eab\u306f\u3053\u3046\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>methods: {\r\n    <strong>start() {<\/strong>\r\n\r\n<strong>        this.seconds = 0;<\/strong>\r\n\r\n<strong>        if(this.timer != null) {<\/strong>\r\n\r\n<strong>            clearInterval(this.timer);<\/strong>\r\n\r\n<strong>        }<\/strong>\r\n\r\n<strong>        this.timer = setInterval(() =&gt; {<\/strong>\r\n\r\n<strong>            this.seconds++;<\/strong>\r\n\r\n<strong>        }, 1000);<\/strong>\r\n\r\n<strong>    },<\/strong>\r\n    \r\n    \/\/ \u7701\u7565\r\n\r\n},<\/pre>\n<p>\u307e\u305a\u306f\u59cb\u3081\u306b<code>timer<\/code>\u304c<code>null<\/code>\u304b\u3069\u3046\u304b\u3092\u30c1\u30a7\u30c3\u30af\u3057\u3001\u3082\u3057\u3059\u3067\u306b\u6642\u9593\u30bf\u30a4\u30de\u30fc\u304c\u5b9f\u884c\u3055\u308c\u3066\u3044\u308b\u306a\u3089\u3001<code>clearInterval()<\/code>\u3067\u3053\u308c\u3092\u30af\u30ea\u30a2\u3057\u307e\u3059\u3002<\/p>\n<p>\u305d\u3057\u3066\u3001<code>setInterval()<\/code>\u3067\u3001\uff11\u79d2\uff081000\u30df\u30ea\u79d2\uff09\u3054\u3068\u306b\u5909\u6570<code>seconds<\/code>\u3092\uff11\u305a\u3064\u8db3\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<p>\u3053\u308c\u3067\u6642\u9593\u304c\u7d4c\u3064\u306b\u3064\u308c\u3066\u79d2\u6570\u304c\uff11\u305a\u3064\u5897\u3048\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n<h2>\u8d64\u3044\u4e38\u3092\u30e9\u30f3\u30c0\u30e0\u3067\u8868\u793a\u3059\u308b\u90e8\u5206\u3092\u3064\u304f\u308b<\/h2>\n<p>\u3067\u306f\u3001\u8d64\u3044\u4e38\u3092\u30e9\u30f3\u30c0\u30e0\u3067\u8868\u793a\u3057\u3066\u3001\u305d\u308c\u304c\u30af\u30ea\u30c3\u30af\u3055\u308c\u305f\u3089\u6210\u529f\u30ab\u30a6\u30f3\u30c8\u3092\u8ffd\u52a0\u3057\u3066\u3044\u304f\u90e8\u5206\u3092\u3064\u304f\u3063\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>\u307e\u305a\u306f\u5909\u6570\u3067\u3059\u3002<\/p>\n<pre>data: {\r\n    seconds: 0,\r\n    timer: null,\r\n    <strong>count: 0,\r\n<\/strong>    <strong>currentNumer: 0<\/strong>\r\n},<\/pre>\n<p>\u8d64\u4e38\u306e\u30af\u30ea\u30c3\u30af\u304c\u6210\u529f\u3057\u305f\u3089\u3001\u3053\u306e<code>count<\/code>\u3092\u5897\u3084\u3057\u3066\u3044\u304d\u307e\u3059\u3002<br \/>\n\u307e\u305f\u3001<code>currentNumber<\/code>\u306f\u3001\u73fe\u5728\u8868\u793a\u3055\u308c\u3066\u3044\u308b\u8d64\u4e38\u306e\u756a\u53f7\u3001\u3064\u307e\u308a\u7b54\u3048\u3067\u3059\u3002<\/p>\n<p>\u3067\u306f\u3001\u6b21\u306b<code>1\u301c25<\/code>\u306e25\u500b\u306e\u6570\u5b57\u3092\u30e9\u30f3\u30c0\u30e0\u306b\u3064\u304f\u3063\u3066<code>currentNumber<\/code>\u3092\u66f4\u65b0\u3059\u308b\u30e1\u30bd\u30c3\u30c9<code>setRandomNumber()<\/code>\u3092\u3064\u304f\u308a\u307e\u3059\u3002<\/p>\n<pre>methods: {\r\n\r\n    \/\/ \u7701\u7565\r\n\r\n<strong>    setRandomNumber() {<\/strong>\r\n\r\n<strong>        this.currentNumber = Math.floor((Math.random() * 25) + 1);<\/strong>\r\n\r\n<strong>    },<\/strong>\r\n\r\n    \/\/ \u7701\u7565\r\n\r\n},<\/pre>\n<p>\u305d\u3057\u3066\u3001\u3053\u306e<code>setRandomNumber()<\/code>\u306f<code>start()<\/code>\u306e\u4e00\u756a\u6700\u5f8c\u306e\u90e8\u5206\u3068\uff11\u79d2\u6bce\u306b\u5b9f\u884c\u3055\u308c\u308b<code>setInterval()<\/code>\u306e\u4e2d\u306e\uff12\u30f6\u6240\u3067\u5b9f\u884c\u3059\u308b\u3088\u3046\u306b\u3057\u307e\u3057\u3087\u3046\u3002\uff08\u3064\u307e\u308a\u3001\uff11\u79d2\u6bce\u306b\u30af\u30ea\u30c3\u30af\u3059\u3079\u304d\u5834\u6240\u304c\u5909\u308f\u308a\u307e\u3059\uff09<\/p>\n<p>\u307e\u305f\u3001\u6210\u529f\u30ab\u30a6\u30f3\u30c8\u304c\u5206\u304b\u308b<code>count<\/code>\u3082\u30b2\u30fc\u30e0\u304c\u30b9\u30bf\u30fc\u30c8\u3057\u305f\u3089\u3059\u3050\u306b\u521d\u671f\u5316\u3059\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/p>\n<pre>start() {\r\n\r\n    \/\/ \u7701\u7565    \r\n\r\n    <strong>this.count = 0;<\/strong>\r\n\r\n    \/\/ \u7701\u7565\r\n\r\n    this.timer = setInterval(() =&gt; {\r\n\r\n        <strong>this.setRandomNumber();<\/strong>\r\n        this.seconds++;\r\n\r\n    }, 1000);\r\n\r\n    <strong>this.setRandomNumber();<\/strong>\r\n\r\n},<\/pre>\n<p>\u6b21\u306b\u3001CSS\u3067\u5b9f\u969b\u306b\u8d64\u4e38\u3092\u8868\u793a\u3059\u308b\u90e8\u5206\u3067\u3059\u3002<\/p>\n<p>\u307e\u305a\u3001<code>class<\/code>\u3092\u30e1\u30bd\u30c3\u30c9\u3067\u4f5c\u6210\u3059\u308b\u3088\u3046<code>:class<\/code>\u3078\u5909\u66f4\u3057<code>buttonClass()<\/code>\u3092\u767b\u9332\u3057\u307e\u3059\u3002<\/p>\n<pre>&lt;span v-for=\"buttonNumber in 25\"&gt;\r\n    &lt;button <strong>:class=\"buttonClass(buttonNumber)\"<\/strong>&gt;&lt;\/button&gt;\r\n    &lt;br v-if=\"buttonNumber%5 == 0\"&gt;\r\n&lt;\/span&gt;<\/pre>\n<p><code>buttonClass()<\/code>\u306e\u4e2d\u8eab\u306f\u3053\u3046\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre><strong>buttonClass(number) {<\/strong>\r\n\r\n<strong>    let classNames = ['circle-button'];<\/strong>\r\n\r\n<strong>    if(number == this.currentNumber) {<\/strong>\r\n\r\n<strong>        classNames.push('current-button');<\/strong>\r\n\r\n<strong>    }<\/strong>\r\n\r\n<strong>    return classNames;<\/strong>\r\n\r\n<strong>}<\/strong><\/pre>\n<p>\u3084\u3063\u3066\u3044\u308b\u306e\u306f\u3001\u30e9\u30f3\u30c0\u30e0\u306b\u3064\u304f\u3089\u308c\u305f\u756a\u53f7\u3068\u73fe\u5728\u306e\u756a\u53f7\u304c\u540c\u3058\u5834\u5408\u306b\u8d64\u4e38\u306e\u30af\u30e9\u30b9\u3001<code>current-button<\/code>\u3092\u8ffd\u52a0\u3057\u3066\u3044\u308b\u3060\u3051\u3067\u3059\u3002<\/p>\n<p>\u3053\u308c\u3067\u8d64\u4e38\u304c\u30e9\u30f3\u30c0\u30e0\u306b\u8868\u793a\u3055\u308c\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u305f\u3002<br \/>\n<span style=\"font-size: 1rem;\">\u30c6\u30b9\u30c8\u3067\u5b9f\u884c\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2309\" style=\"border: 1px solid #ccc;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/11\/vue_reflexes_4.png\" alt=\"\" width=\"528\" height=\"699\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/11\/vue_reflexes_4.png 528w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/11\/vue_reflexes_4-227x300.png 227w\" sizes=\"auto, (max-width: 528px) 100vw, 528px\" \/><\/p>\n<h2>\u4e38\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3057\u305f\u3068\u304d\u306e\u30b3\u30fc\u30c9\u3092\u3064\u304f\u308b<\/h2>\n<p>\u3067\u306f\u3001\u6700\u5f8c\u306b\u4e38\u30dc\u30bf\u30f3\u304c\u30af\u30ea\u30c3\u30af\u3055\u308c\u305f\u3068\u304d\u306e\u30b3\u30fc\u30c9\u3067\u3059\u3002<\/p>\n<pre>&lt;button\r\n    :class=\"buttonClass(buttonNumber)\"\r\n    <strong>@click=\"answer(buttonNumber)\"<\/strong>&gt;&lt;\/button&gt;<\/pre>\n<p>\u307e\u305a\u4e38\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3057\u305f\u3068\u304d\u306b<code>answer()<\/code>\u304c\u5b9f\u884c\u3055\u308c\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/p>\n<pre>methods: {\r\n    answer(number) {\r\n\r\n        <strong>if(number == this.currentNumber) {<\/strong>\r\n\r\n<strong>            this.count++;<\/strong>\r\n\r\n<strong>            if(this.count == 10) {<\/strong>\r\n\r\n<strong>                clearInterval(this.timer);<\/strong>\r\n<strong>                alert(\"\u30b4\u30fc\u30eb\uff01\\n\u7d50\u679c\u306f\u3001\u300c\"+ this.secondsInHMS +\"\u300d\u3067\u3057\u305f\u3002\");<\/strong>\r\n\r\n<strong>            }<\/strong>\r\n\r\n<strong>            this.setRandomNumber();<\/strong>\r\n\r\n<strong>        } else { \/\/ \u30da\u30ca\u30eb\u30c6\u30a3<\/strong>\r\n\r\n<strong>            this.seconds += 10;<\/strong>\r\n\r\n<strong>        }<\/strong>\r\n\r\n    },\r\n\r\n    \/\/ \u7701\u7565<\/pre>\n<p><code>answer()<\/code>\u306e\u4e2d\u3067\u306f\u3001\u30af\u30ea\u30c3\u30af\u3055\u308c\u305f\u30dc\u30bf\u30f3\u756a\u53f7\u3068\u30e9\u30f3\u30c0\u30e0\u756a\u53f7\u304c\u540c\u3058\u304b\u3092\u30c1\u30a7\u30c3\u30af\u3057\u3066\u3001\u3082\u3057\u540c\u3058\uff08\u6b63\u89e3\uff09\u306a\u3089<code>count<\/code>\u3092\uff11\u5897\u3084\u3057\u307e\u3059\u3002\u305d\u3057\u3066\u3001\u3082\u3057\u6210\u529f\u30ab\u30a6\u30f3\u30c8\u304c<code>10<\/code>\u306b\u306a\u3063\u305f\u3089\u30bf\u30a4\u30de\u30fc\u3092\u6b62\u3081\u3001\u30b2\u30fc\u30e0\u5b8c\u4e86\u306e\u30a2\u30e9\u30fc\u30c8\u3092\u8868\u793a\u3057\u307e\u3059\u3002<\/p>\n<p>\u9006\u306b\u9593\u9055\u3063\u305f\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3057\u305f\u5834\u5408\u306f+10\u79d2\u306e\u30da\u30ca\u30eb\u30c6\u30a3\u3067\u3059\u3002<\/p>\n<h1>\u30c7\u30e2\u3092\u7528\u610f\u3057\u307e\u3057\u305f<\/h1>\n<p>\u4eca\u56de\u958b\u767a\u3057\u305f\u53cd\u5c04\u795e\u7d4c\u30b2\u30fc\u30e0\u306f\u4ee5\u4e0b\u304b\u3089\u4f53\u9a13\u3067\u304d\u307e\u3059\u3002<\/p>\n<p><a href=\"https:\/\/demo-laravel52.capilano-fw.com\/vue_reflexes\" target=\"_blank\" rel=\"noopener\">Vue\u3067\u53cd\u5c04\u795e\u7d4c\u30b2\u30fc\u30e0\uff01<\/a><\/p>\n<p>\u203b \u306a\u304aIE\u306f\u5bfe\u5fdc\u3057\u3066\u307e\u305b\u3093\u3002\uff08\u30b4\u30e1\u30f3\u30ca\u30b5\u30a4&#8230;IE\u306f\u3082\u3046\u898b\u9650\u3063\u305f\u3093\u3067\u3059T^T\uff09<\/p>\n<h1>\u6559\u6750\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9<\/h1>\n<p>\u4eca\u56de\u5b9f\u969b\u306b\u958b\u767a\u3057\u305f\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u4e00\u5f0f\u3092\u4ee5\u4e0b\u304b\u3089\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<code>cdn<\/code>\u3092\u4f7f\u3063\u3066\u3044\u308b\u306e\u3067\u3001\u5c55\u958b\u3057\u3066<code>index.html<\/code>\u3092\u958b\u304f\u3060\u3051\u3067\u5b9f\u884c\u3067\u304d\u307e\u3059\u3088\uff01<\/p>\n<a  data-e-Disable-Page-Transition=\"true\" class=\"download-link\" title=\"\" href=\"https:\/\/blog.capilano-fw.com?download=2310&amp;tmstv=1777660159\" rel=\"nofollow\" id=\"download-link-2310\" data-redirect=\"false\" >\n\tVueJS\u3067\u53cd\u5c04\u795e\u7d4c\u30b2\u30fc\u30e0<\/a>\n\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3055\u3066\u3055\u3066\u3001\u3053\u306e\u3068\u3053\u308dElectron\u958b\u767a\u304c\u697d\u3057\u3044\u306e\u3067\u305d\u3061\u3089\u95a2\u9023\u306e\u8a18\u4e8b\u304c\u591a\u304f\u306a\u3063\u3066\u3044\u307e\u3059\u304c\u3001\u3084\u306f\u308a\u305f\u307e\u306b\u306f\u305d\u306e\u4ed6\u306e\u8a71\u984c\u3082\u3001\u3068\u3044\u3046\u3053\u3068\u3067\u4eca\u56de\u306fVue.js\u3092\u4f7f\u3063\u305f\u958b &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/blog.capilano-fw.com\/?p=2302\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;\u610f\u5916\u3068\u7c21\u5358\uff01VueJS\u3067\u53cd\u5c04\u795e\u7d4c\u30b2\u30fc\u30e0\u3092\u3064\u304f\u3063\u3066\u307f\u3088\u3046\uff08\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u53ef\uff09&#8221; \u306e<\/span>\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":2303,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,97],"tags":[112],"class_list":["post-2302","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-vue-js","category-97","tag-112"],"_links":{"self":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/2302","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=2302"}],"version-history":[{"count":5,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/2302\/revisions"}],"predecessor-version":[{"id":2415,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/2302\/revisions\/2415"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/media\/2303"}],"wp:attachment":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2302"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2302"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2302"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}