Associate request with props using vue-router

Is it possible to declaratively bind request values ​​to details?

I want /my-foo?bar=my-barto transfer the details {foo: "my-foo", bar: "my-bar"}.

I am currently using something like this:

export default new Router({
  routes: [
    {
      path: "/:foo",
      name: "Foo",
      component: FooPage,
      props: route => ({ foo: route.params.foo, bar: route.query.bar})
    }
  ]
});

And I'm looking for something like:

export default new Router({
  routes: [
    {
      path: "/:foo?bar=:bar",
      name: "Foo",
      component: FooPage,
      props: true
    }
  ]
});

I am using vue-router 2.3.1

+4
source share

Source: https://habr.com/ru/post/1680227/


All Articles