New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding name mode section in passing props to route component #2499

Open
wants to merge 1 commit into
base: dev
from

Conversation

Projects
None yet
3 participants
@suprabhasupi

suprabhasupi commented Nov 26, 2018

Fixes (#2493)

@suprabhasupi

This comment has been minimized.

suprabhasupi commented Nov 29, 2018

@posva Is there any issue with this PR. Why its is not getting merged? Please let me if there are changes to be done.

@posva

This comment has been minimized.

Member

posva commented Nov 29, 2018

No, no problems. It's not getting merged yet because I haven't checked :)

@autumnwoodberry

This behavior is not really one of the "modes" and the example in the documentation has a comment/example that explains it already:

// for routes with named views, you have to define the `props` option for each named view:
{
  path: '/user/:id',
  components: { default: User, sidebar: Sidebar },
  props: { default: true, sidebar: false }
}

Perhaps we could remove this comment/example from the code at the top of the page and move it to a new section at the bottom titled "Usage with named views". This way it would be explained as an explicit feature which would be harder to miss. You could even mention that the rules still apply for using the different modes. Maybe something like this:

## Usage with named views

A route with [named views](named-views.html) must have an explicitly defined `props` option for each named view.

In the following example, the `header` and `default` views will recieve the `id` prop, but the `footer` view will not.

```js
const router = new VueRouter({
  routes: [
    {
      path: '/user/:id',
      components: {
        header: Header,
        default: User,
        footer: Footer
      },
      props: {
        header: true,
        default: true,
      }
    }
  ]
});
```

The `props` option for each named view can still be defined using any of the available modes:

```js
const router = new VueRouter({
  routes: [
    {
      path: '/user/:id',
      components: {
        header: Header,
        default: User,
        footer: Footer
      },
      props: {
        header: { sticky: true },
        default: route => route.query,
        footer: true,
      }
    }
  ]
})
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment