Can vue-router use regex route matching and pass the match as a named parameter

1.3k views Asked by At

Under the hood, I understand the vue-router uses path-to-regexp to handle route matching.

If I use the route format:

/app/:collection(/^cases$?)/:id 

This matches the route /app/cases/abc123 and directs to the component just fine but doesn't store { collection: 'cases' } on the $route.params object which is what I also need. Is there another way to do this?

1

There are 1 answers

0
Tremendus Apps On

My bad, I misunderstood the syntax of path-to-regexp in the docs.

The route matching should have been:

/app/:collection(cases)/:id

.. then you get the route matching with the parameter passed.

I'm unclear if its appropriate to answer the question as correction or delete it. I'm sure someone will let me know ;)