vue router /:param with slashes

Viewed 6724

I have a router like this:

routes: [
    {
      path: '/survey/:surveyHash',
      name: 'survey',
      component: Survey,
      props: true,
    },

In the component I'm trying to get surveyHash in props. The trouble is I can't do it when there are / slashes inside surveyHash.

Is there a solution in vue-router?

2 Answers

You can use a custom matching pattern in your route definition

routes: [
    {
      path: '/survey/:surveyHash(.*)',
      name: 'survey',
      component: Survey,
      props: true,
    },

With this you will get the rest of the URL including slashes in surveyHash

Related