Reputation: 58
I have a question about router base for example I have a nuxt project with pages like this :
- pages
- a
- index.vue
- b
- index.vue
I made a router base = '/a/', so when I run the project, the URL will directly go to base router, https://localhost:3000/a
It didn't show the index.vue on pages a. I should use the URL https://localhost:3000/a/a to show the index.vue on pages a.
My question is, is it normally like that ? Or there is any other way to use URL https://localhost:3000/a to directly open index.vue on pages a ?
Upvotes: 0
Views: 815
Reputation: 46604
You can install and setup this package: https://github.com/nuxt-community/router-extras-module
Then, you can have the content of the page a
on /
with the following
/pages/a.vue
<router>
{
alias: '/'
}
</router>
<template>
<div>Content page A</div>
</template>
No need for a /pages/index.vue
in this case btw.
Or you can have a redirect and see the content of page a
on /a
with the following
/pages/index.vue
<router>
{
redirect: '/a'
}
</router>
/pages/a.vue
<template>
<div>Content page A</div>
</template>
PS: since this is related to router configuration, keep in mind that a server restart may be mandatory to take the updates into account.
Upvotes: 1