-
-
Notifications
You must be signed in to change notification settings - Fork 5k
[2.0] default named child routes not being matched #608
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
Comments
I'd say this is expected behavior - named routes are precise targets, i.e. when you specify |
I know this issue is old but I completely disagree. I made the default child the default for a reason and now I can never refer to my route with I found this issue specifically because I was confused by this so-called "expected" behavior. I actually expected my default child to be rendered any time I visit that parent route/component, regardless of how I link to it |
@joemsak I also found this behavior intuitive and it was problematic for me when I attempted to implement an "up" button to navigate up the site hierarchy. I could programatically find the name of the current route's parent, but finding the name of that parent's defaultChild was problematic. Fortunately, there is a workaround described at #822 (comment) to give the behavior that we expect. new Router({
routes: [{
path: "/parent/:someProp",
component: Parent,
name: "parent",
// explicitly reroute to default child on named navigation
// https://github.com/vuejs/vue-router/issues/822#issuecomment-255685008
redirect: "/parent/:someProp",
children: [
{
path: "",
name: "defaultChild",
component: DefaultChild
},
// ... |
Vue.js & vue-router.js version
2.0.0.rc3
Reproduction Link
https://jsfiddle.net/u5jjwzft/9/
Steps to reproduce
Click on the links and you will see that when using the router-link with
:to="{name: 'parent'}"
wil not load defaultWhat is Expected?
When either you use
to="/parent"
or:to="{name:'parent'}"
you expect to see the default child route component.What is actually happening?
It is not showing the default child route component.
On first page load of
/parent
it works but when clicking on one link and then to the named route it doesn't work.The text was updated successfully, but these errors were encountered: