Vue-router: Named/multiple outlets support

Created on 2 Nov 2015  ·  13Comments  ·  Source: vuejs/vue-router

It would be very nice to have named outlet support.

It's mostly to have easy modals support and being able to write something like:

<body>
<div>
   <router-view name="modal"></router-view>
</div>
<router-view ></router-view>
</body>
router.map({
    '/somewhere/': {
        component: Somewhere,
        subRoutes: {
            'action/': {
                 component: Modal,
                 outlet: 'modal'
            }
        }
    }
});

Then, routing to /somewhere/action/ should bring the Somewhere component and display the modal over.

My case is for modal, but I think whenever you have an outer layout with multiple reusable slots, a single outlet is not sufficient.

If there is already a way of doing this, I'm interested in.

1.x feature request

Most helpful comment

This is available in vue-router 2.0.0-rc.* (which is only compatible with Vue 2.0).

Work on vue-router 0.7.* won't really go on until all the 2.0 related release work is done.

@djvonavi If you want to work on a PR, that would be welcome.

All 13 comments

:+1: Would love something like this.

:+1:

I think this can be achieved by using named routes, no? Like <modal v-if="$router.name === 'modal'"></modal>.

To add on to what @azamat-sharapov stated, the named routes feature is documented here: http://vuejs.github.io/vue-router/en/named.html

Though since I believe this use case to be common then I think a cleaner API to handle it would be nice, instead of having $router.name === 'modal' all over.

+1s. Will this be implemented?

Yeah, still waiting for it to implement.

Hi! May be need help? Because it's very important issue(((

This is available in vue-router 2.0.0-rc.* (which is only compatible with Vue 2.0).

Work on vue-router 0.7.* won't really go on until all the 2.0 related release work is done.

@djvonavi If you want to work on a PR, that would be welcome.

How is this possible? Any documentation?

No, this is not possible for Vue-router < 2.0, and we likely won't implement it.

Thanks, Is it possible on Vue-router 2.0?

yes, it is, as the comment above says. Search for named views

@posva Can we update the labels of this issue or close it? I don't think this will be implemented for v1.x

Was this page helpful?
0 / 5 - 0 ratings