Home > Software engineering >  Nuxt Router Push without Changing Page
Nuxt Router Push without Changing Page

Time:08-27

I have a homepage which is paginated, though when clicking "Next Page" it seems to be looking for a page named /page/1. Is there a way to paginate the index.vue page without creating a brand new page?

I've currently implemented the following on @click.

  this.$router.push({
    path: '/'   this.page,
    query: { },
  })

CodePudding user response:

You can have dynamic parameters.

For example

url.com/1

url.com/2

So if your home page is index.vue, you need to create a vue file next to it for a dynamic parameter with name after an underscore, for example _id.vue

So the param after the root URL will be mapped to this page.

For more resources about file system and routing in NUXT

  • Related