LoginSignup
5
2

More than 3 years have passed since last update.

Nuxt.jsでのルートパスのテンプレートをindex.vueからtop.vueに変更する

Last updated at Posted at 2020-01-09

編集するファイルは、.nuxt/route.js

router.jsのファイルを開いてみると、以下のような記述があると思います。

router.js
export const routerOptions = {

・・・・

  routes: [{
    path: "/top",
    component: _702885f1,
    name: "top"
  }, {
    path: "/",
    component: _2458d5ee,
    name: "index"
  }],

Nuxt.jsはディレクトリ構造でパスを決定する仕組みになっていますが、実はその設定はここに記載されています。

一番下で、ルートパスがindex.vueを参照するようにデフォルトで設定されてます。

この部分を書き換えてやれば、完了です。

router.js
export const routerOptions = {

・・・・

  routes: [{
    path: "/top",
    component: _702885f1,
    name: "top"
  }, {
    path: "/",
    component: _2458d5ee,
    name: "top" // 変更
  }],

僕の場合、ルートパスで、top.vueを参照して欲しいので上記のように変更しました。

5
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
2