S
S
startproger2022-01-10 19:12:04
Vue.js
startproger, 2022-01-10 19:12:04

Is it possible to make the route parameter not after the slash, but after the letter in Vue (2, 3)?

In vue router, you can make the following route: /page/:nwhere n is a parameter, respectively, the page will be /page/1 , etc.

Is it possible to make the parameter NOT after the slash, so that you can make a page like this: /page1 ?

This implementation in Nuxt is especially interesting when using routing on files.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander, 2022-01-12
@startproger

You can use regular expressions in path:

{
  path: "/page:id([0-9]+)", ...
}

https://codesandbox.io/s/peaceful-banach-wjg4o

D
Dima Pautov, 2022-01-10
@bootd

Why not just do it then /:n?
In nuxt in the page root directory, create _id.vueeverything
PS

This implementation in Nuxt is especially interesting when using routing on files.

In nuxt, routing may not necessarily be on files, you can write a router and handles as in normal vue
https://nuxtjs.org/docs/configuration-glossary/con...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question