erraX / nuxt-router-module

load nuxt router configs automatically.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

nuxt-router-module

Features

Disable nuxt built-in router configs(building router configs from pages directory).
You can use this module to load router configs automatically.

Installation

$ npm install nuxt-router-module

Setup

  1. module configuration
// nuxt.config.js
export default {
  modules: [
    [
      'nuxt-router-module',
      {
        /* module options */
      },
    ],
  ],

  // or
  routerModule: {
    /* module options */
    path: '~/routes',
    fileName: 'index.js',
  },
};
  1. routes configuration
// ~/routes/index.js

export default [
  {
    path: '/home',
    component: Home,
    // ... router configs
  },
];

Options

  • path

    Location of your route file

    • Type: string
    • Default: ~
  • fileName

    File name of your routes configuration in path Must export valid Vue routes

    • Type: string
    • Default: index.js
  • routerOptions

    Same as vue-router router options

About

load nuxt router configs automatically.


Languages

Language:JavaScript 96.0%Language:Vue 4.0%