Reputation: 11
I'm trying to set up routing on a site (Nuxt.js) Using @nuxtjs/router to create my own router.js file. Faced the problem of locating dynamic and static routes on the same level. I have the structure like this:
/:slug
/contacts
Opening /contacts get the wrong page with slug "contacts"
To change the structure e.g./hotels/:slug is not the way out for my situation. So.. how can i do this? Is there a way to set the priority of routes. Digging in the direction of extendRoutes did not bring any results.
Upvotes: 1
Views: 1640
Reputation: 11
You should put your static pages inside their own folder with their own index.vue
example:
_slug
index.vue
features
index.vue
contacts
index.vue
Upvotes: 1
Reputation: 1073
Try this: create a folder named contacts
a file inside the folder named index.vue
. Now create another file named _slug.vue
in the same level as the index.vue
.
It will be something like this:
--contacts
|--- _slug.vue
|--- index.vue
Now the route /contacts/
will open the index.vue
and contacts/something
opens up _slug.vue
with something
as a slug.
Upvotes: 2