I am creating a VueJS app which heavily uses the vue router.
Here's the structure of my routes.js:
export const routes = [
{ path: '', component: Poetry, children: [
{ path: '', name: 'poetry', component: PoetryLanding },
{ path: 'poetry/:id', name: 'poetrycard', component: PoetryCard },
{ path: 'poetry/search', name: 'poetrysearch', component: PoetrySearch },
]},
]
I want to use regex in second child component i.e. poetrycard such that it only accepts the params(:id) which is a number. I am doing this because poetrysearch gets affected as /search is treated as :id!
I tried:
{ path: 'poetry/:id/[0-9]/g', name: 'poetrycard', component: PoetryCard }
But this doesn't work. Please help.