Tremendus Apps
Tremendus Apps

Reputation: 1555

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

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?

Upvotes: 0

Views: 1474

Answers (1)

Tremendus Apps
Tremendus Apps

Reputation: 1555

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 ;)

Upvotes: 1

Related Questions