{"id":5729,"date":"2018-07-14T19:53:23","date_gmt":"2018-07-14T10:53:23","guid":{"rendered":"http:\/\/www.code-magagine.com\/?p=5729"},"modified":"2023-05-27T21:40:55","modified_gmt":"2023-05-27T12:40:55","slug":"%e3%80%90nuxt-js%e3%80%91%e3%80%8c%e3%83%ab%e3%83%bc%e3%83%86%e3%82%a3%e3%83%b3%e3%82%b0%e8%a8%ad%e5%ae%9a%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=5729","title":{"rendered":"\u3010Nuxt.js\u3011\u4f5c\u6210\u3057\u305f\u30da\u30fc\u30b8\u306e\u300c\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u300d\u3092\u3055\u305b\u3066\u307f\u308b\u3002"},"content":{"rendered":"<h2>\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u8a2d\u5b9a\uff08.nuxt\/router.js\uff09<\/h2>\n<p>nuxt.js\u306e\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u306e\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u306a\u304a\u3001<span style=\"color: #ff0000;\"><strong>pages\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u914d\u4e0b\u306b\u65b0\u3057\u3044\u30da\u30fc\u30b8\u3092\u4f5c\u6210\u3059\u308b\u3068\u3001routes\u30d7\u30ed\u30d1\u30c6\u30a3\u306e\u914d\u5217\u306b\u30da\u30fc\u30b8\u304c\u8ffd\u52a0\u3055\u308c\u307e\u3059\u3002<\/strong><\/span><\/p>\n<pre class=\"lang:default decode:true\">export function createRouter () {\r\n  return new Router({\r\n    mode: 'history',\r\n    base: '\/',\r\n    linkActiveClass: 'nuxt-link-active',\r\n    linkExactActiveClass: 'nuxt-link-exact-active',\r\n    scrollBehavior,\r\n    routes: [\r\n                {\r\n                        path: \"\/\",\r\n                        component: _1b60ecdc,\r\n                        name: \"index\"\r\n                }\r\n    ],\r\n\r\n\r\n    fallback: false\r\n  })\r\n}<\/pre>\n<h3>routes\u30d7\u30ed\u30d1\u30c6\u30a3\u914d\u4e0b\u306b\u4e0b\u8a18\u306e\u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u6307\u5b9a\u3059\u308b\u3053\u3068\u3067\u3001URL\u306e\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u8a2d\u5b9a\u304c\u3067\u304d\u307e\u3059\u3002<\/h3>\n<table>\n<tbody>\n<tr>\n<th>\u30aa\u30d7\u30b7\u30e7\u30f3<\/th>\n<th>\u8aac\u660e<\/th>\n<\/tr>\n<tr>\n<td>path<\/td>\n<td>pages\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u914d\u4e0b\u306e\u30d1\u30b9\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/td>\n<\/tr>\n<tr>\n<td>name<\/td>\n<td>pages\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u914d\u4e0b\u306e\u30d5\u30a1\u30a4\u30eb\u540d\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>\u52d5\u7684\u306b\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u3055\u305b\u308b\u306b\u306f\uff1f<\/h2>\n<h3>pages\/index.vue<\/h3>\n<pre class=\"lang:default decode:true \">&lt;template&gt;\r\n  &lt;section class=\"container\"&gt;\r\n    &lt;div&gt;\r\n      &lt;nuxt-link to=\"articles\/1\"&gt;User&lt;\/nuxt-link&gt;\r\n    &lt;\/div&gt;\r\n  &lt;\/section&gt;\r\n&lt;\/template&gt;<\/pre>\n<h3>pages\/articles\/_id.vue<\/h3>\n<p>\u52d5\u7684\u306a\u5024\u3092\u4f7f\u3046\u306b\u306f\u3001\u30d5\u30a1\u30a4\u30eb\u540d\u304b\u3001\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u540d\u306b<span style=\"color: #ff0000;\"><strong>\u300c_\u300d\uff08\u30a2\u30f3\u30c0\u30fc\u30b9\u30b3\u30a2\u306e\u30d7\u30ec\u30d5\u30a3\u30c3\u30af\u30b9\uff09<\/strong><\/span>\u3092\u3064\u3051\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true\">&lt;template&gt;\r\n&lt;div&gt;\r\n  id:{{ $route.params.id }}\r\n&lt;\/div&gt;\r\n&lt;\/template&gt;<\/pre>\n<p>\u307e\u305f\u3001\u9077\u79fb\u5148\u306e\u30da\u30fc\u30b8\u3067\u306f\u3001\u300c{{ $route.params.id }}\u300d\u3068\u3044\u3046\u3088\u3046\u306b\u6307\u5b9a\u3059\u308c\u3070\u3001\u52d5\u7684\u306a\u5024\u3092\u753b\u9762\u306b\u8868\u793a\u3055\u305b\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<h3>\u5b9f\u884c\u7d50\u679c<\/h3>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-5736\" src=\"http:\/\/www.code-magagine.com\/wp-content\/uploads\/2018\/07\/nuxt.js\u5b9f\u884c\u7d50\u679c\uff11.png\" alt=\"\" width=\"287\" height=\"97\" \/><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-5737\" src=\"http:\/\/www.code-magagine.com\/wp-content\/uploads\/2018\/07\/nuxt.js\u5b9f\u884c\u7d50\u679c\uff12.png\" alt=\"\" width=\"364\" height=\"106\" srcset=\"http:\/\/www.code-magagine.com\/wp-content\/uploads\/2018\/07\/nuxt.js\u5b9f\u884c\u7d50\u679c\uff12.png 364w, http:\/\/www.code-magagine.com\/wp-content\/uploads\/2018\/07\/nuxt.js\u5b9f\u884c\u7d50\u679c\uff12-300x87.png 300w\" sizes=\"(max-width: 364px) 100vw, 364px\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u8a2d\u5b9a\uff08.nuxt\/router.js\uff09 nuxt.js\u306e\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u306e\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u306b\u306a\u308a\u307e\u3059\u3002 \u306a\u304a\u3001pages\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u914d\u4e0b\u306b\u65b0\u3057\u3044\u30da\u30fc\u30b8\u3092\u4f5c\u6210\u3059\u308b\u3068\u3001routes\u30d7\u30ed\u30d1\u30c6\u30a3\u306e\u914d\u5217\u306b\u30da\u30fc\u30b8\u304c\u8ffd\u52a0\u3055\u308c\u307e\u3059\u3002 [&hellip;]","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[61],"tags":[],"_links":{"self":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/5729"}],"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=5729"}],"version-history":[{"count":7,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/5729\/revisions"}],"predecessor-version":[{"id":20384,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/5729\/revisions\/20384"}],"wp:attachment":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5729"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5729"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5729"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}