when using the following directory structure
dir: blog/
dir: blog/_country/
dir: blog/_country/_year
file: blog/_country/_year/index.vue
file: blog/_country/_year/_slug.vue
and the following content of file blog/_country/_year/index.vue
async asyncData({ params }) {
console.log(params)
}
go to http://localhost:3000/blog/new-zealand
{
country: 'new-zealand',
year: undefined,
}
{
country: undefined,
year: 'new-zealand',
}
params are not correctly matched with _params in folders/files
FYI: this works as expected in [email protected] and [email protected] but has stopped working from 2.14.1 onwards
I believe this is the correct behavior based on your directory structure.
You should create file blog/_country/index.vue to handle /blog/new-zealand as you expected.
With your structure router will create two routes.
/blog/:country?/:year/blog/:country?/:year?/:slugOn the page /blog/new-zealand router matches with first route. As you see :year params is required and :country is optional, so router use new-zealand for :year and left :country empty
@farnabaz Thanks for that clear explanation.
Most helpful comment
I believe this is the correct behavior based on your directory structure.
You should create file
blog/_country/index.vueto handle/blog/new-zealandas you expected.Explanations:
With your structure router will create two routes.
/blog/:country?/:year/blog/:country?/:year?/:slugOn the page
/blog/new-zealandrouter matches with first route. As you see:yearparams is required and:countryis optional, so router usenew-zealandfor:yearand left:countryempty