{"id":13977,"date":"2025-11-20T10:00:00","date_gmt":"2025-11-20T01:00:00","guid":{"rendered":"https:\/\/www.gigas-jp.com\/appnews\/?p=13977"},"modified":"2025-11-19T17:23:34","modified_gmt":"2025-11-19T08:23:34","slug":"vue-js%e3%81%ae%e5%9f%ba%e6%9c%ac-2","status":"publish","type":"post","link":"https:\/\/www.gigas-jp.com\/appnews\/archives\/13977","title":{"rendered":"Vue.js\u306e\u57fa\u672c #2"},"content":{"rendered":"\n<p><a href=\"https:\/\/www.gigas-jp.com\/appnews\/archives\/13958\" target=\"_blank\" rel=\"noreferrer noopener\">\u524d\u56de<\/a>\u306b\u5f15\u304d\u7d9a\u304dJavaScript\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u306eVue.js\u306e\u57fa\u672c\u306b\u3064\u3044\u3066\u8aac\u660e\u3057\u307e\u3059\u3002<br>Vue.js\u306f\u3001HTML\u306b\u52d5\u304d\u3092\u3064\u3051\u305f\u308a\u3001\u30e6\u30fc\u30b6\u30fc\u64cd\u4f5c\u306b\u5fdc\u3058\u3066\u30ea\u30a2\u30eb\u30bf\u30a4\u30e0\u306b\u753b\u9762\u3092\u66f4\u65b0\u3057\u305f\u308a\u3059\u308b\u305f\u3081\u306e\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3067\u3059\u3002<br>\u3053\u306e\u8a18\u4e8b\u3067\u306f\u3001Vue.js\u306e\u4e2d\u3067\u3082\u7279\u306b\u3088\u304f\u4f7f\u308f\u308c\u308b \u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u69cb\u6587\uff08HTML\u5074\uff09 \u3068 \u30ed\u30b8\u30c3\u30af\uff08JavaScript\u5074\uff09\u3092\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h4>JavaScript\u5074\u306e\u57fa\u672c\u69cb\u9020<\/h4>\n\n\n\n<p>Vue 3 \u3067\u306f Composition API\uff08setup\u95a2\u6570\uff09 \u3068 Options API\uff08data, methods, computed\u306a\u3069\uff09 \u306e2\u901a\u308a\u304c\u3042\u308a\u307e\u3059\u3002<br>\u3053\u3053\u3067\u306f\u4e21\u65b9\u3092\u7c21\u5358\u306b\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<p>setup()\uff1aComposition API\u306e\u30a8\u30f3\u30c8\u30ea\u30fc\u30dd\u30a4\u30f3\u30c8<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import { reactive  } from 'vue';\n\nexport default {\n  setup() {\n    \/\/ reactive\u3092\u4f7f\u3063\u3066\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u5168\u4f53\u3092\u30ea\u30a2\u30af\u30c6\u30a3\u30d6\u306b\u3059\u308b\n    const state = reactive({\n      count: 0,\n      message: '\u3053\u3093\u306b\u3061\u306f\uff01'\n    });\n\n    const increment = () =&gt; {\n      state.count++;\n    };\n\n    return { state, increment };\n  }\n};<\/code><\/pre>\n\n\n\n<p><br>\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u5074\u306e\u4f7f\u3044\u65b9<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;template&gt;\n  &lt;div&gt;\n    &lt;p&gt;{{ state.message }}&lt;\/p&gt;\n    &lt;p&gt;\u30af\u30ea\u30c3\u30af\u56de\u6570\uff1a{{ state.count }}&lt;\/p&gt;\n    &lt;button @click=\"increment\"&gt;\u30ab\u30a6\u30f3\u30c8\u30a2\u30c3\u30d7&lt;\/button&gt;\n  &lt;\/div&gt;\n&lt;\/template&gt;<\/code><\/pre>\n\n\n\n<p><br>reactive() \u306f \u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u5168\u4f53\u3092\u30ea\u30a2\u30af\u30c6\u30a3\u30d6\uff08\u53cd\u5fdc\u7684\uff09\u306b\u5909\u63db \u3057\u307e\u3059\u3002<br>\u21d2 state.count \u306e\u3088\u3046\u306b\u76f4\u63a5\u30d7\u30ed\u30d1\u30c6\u30a3\u3092\u53c2\u7167\u3067\u304d\u307e\u3059\uff08ref \u306e\u3088\u3046\u306b .value \u306f\u4e0d\u8981\uff09\u3002<\/p>\n\n\n\n<p>ref() \u306f\u5358\u4e00\u306e\u5024\u3092\u30ea\u30a2\u30af\u30c6\u30a3\u30d6\u306b\u3059\u308b\u306e\u306b\u4fbf\u5229\u3067\u3059\u304c\u3001<br>\u8907\u6570\u306e\u72b6\u614b\u3092\u307e\u3068\u3081\u3066\u7ba1\u7406\u3059\u308b\u306a\u3089 reactive() \u306e\u307b\u3046\u304c\u30b9\u30c3\u30ad\u30ea\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<p>return { state, increment } \u306b\u3088\u308a\u3001HTML\uff08\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\uff09\u5074\u3067 state \u3068 increment \u3092\u4f7f\u3048\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u6b21\u56de\u306fOptions API\u306edata\u3068computed\u306b\u3064\u3044\u3066\u8aac\u660e\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u6728\u66dc\u65e5\u62c5\u5f53\uff1anishida<\/p>\n\n\n\n<p><\/p>\n<div class='wp_social_bookmarking_light'>\n            <div class=\"wsbl_google_plus_one\"><g:plusone size=\"medium\" annotation=\"none\" href=\"https:\/\/www.gigas-jp.com\/appnews\/archives\/13977\" ><\/g:plusone><\/div>\n            <div class=\"wsbl_hatena_button\"><a href=\"\/\/b.hatena.ne.jp\/entry\/https:\/\/www.gigas-jp.com\/appnews\/archives\/13977\" class=\"hatena-bookmark-button\" data-hatena-bookmark-title=\"Vue.js\u306e\u57fa\u672c #2\" data-hatena-bookmark-layout=\"standard\" title=\"\u3053\u306e\u30a8\u30f3\u30c8\u30ea\u30fc\u3092\u306f\u3066\u306a\u30d6\u30c3\u30af\u30de\u30fc\u30af\u306b\u8ffd\u52a0\"> <img src=\"\/\/b.hatena.ne.jp\/images\/entry-button\/button-only@2x.png\" alt=\"\u3053\u306e\u30a8\u30f3\u30c8\u30ea\u30fc\u3092\u306f\u3066\u306a\u30d6\u30c3\u30af\u30de\u30fc\u30af\u306b\u8ffd\u52a0\" width=\"20\" height=\"20\" style=\"border: none;\" \/><\/a><script type=\"text\/javascript\" src=\"\/\/b.hatena.ne.jp\/js\/bookmark_button.js\" charset=\"utf-8\" async=\"async\"><\/script><\/div>\n            <div class=\"wsbl_twitter\"><a href=\"https:\/\/twitter.com\/share\" class=\"twitter-share-button\" data-url=\"https:\/\/www.gigas-jp.com\/appnews\/archives\/13977\" data-text=\"Vue.js\u306e\u57fa\u672c #2\" data-via=\"GIGASJAPAN_APPS\" data-lang=\"ja\">Tweet<\/a><\/div>\n            <div class=\"wsbl_facebook_like\"><div id=\"fb-root\"><\/div><fb:like href=\"https:\/\/www.gigas-jp.com\/appnews\/archives\/13977\" layout=\"button_count\" action=\"like\" width=\"100\" share=\"false\" show_faces=\"false\" ><\/fb:like><\/div>\n            <div class=\"wsbl_facebook_send\"><div id=\"fb-root\"><\/div><fb:send href=\"https:\/\/www.gigas-jp.com\/appnews\/archives\/13977\" colorscheme=\"light\" ><\/fb:send><\/div>\n    <\/div>\n<br class='wp_social_bookmarking_light_clear' \/>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u56de\u306b\u5f15\u304d\u7d9a\u304dJavaScript\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u306eVue.js\u306e\u57fa\u672c\u306b\u3064\u3044\u3066\u8aac\u660e\u3057\u307e\u3059\u3002Vue.js\u306f\u3001HTML\u306b\u52d5\u304d\u3092\u3064\u3051\u305f\u308a\u3001\u30e6\u30fc\u30b6\u30fc\u64cd\u4f5c\u306b\u5fdc\u3058\u3066\u30ea\u30a2\u30eb\u30bf\u30a4\u30e0\u306b\u753b\u9762\u3092\u66f4\u65b0\u3057\u305f\u308a\u3059\u308b\u305f\u3081\u306e\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3067\u3059\u3002\u3053\u306e\u8a18\u4e8b\u3067 [&hellip;]<\/p>\n","protected":false},"author":16,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[100],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/posts\/13977"}],"collection":[{"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/users\/16"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/comments?post=13977"}],"version-history":[{"count":7,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/posts\/13977\/revisions"}],"predecessor-version":[{"id":13986,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/posts\/13977\/revisions\/13986"}],"wp:attachment":[{"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/media?parent=13977"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/categories?post=13977"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/tags?post=13977"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}