Skip to content

router.getMatchedComponents() doesn't seem to match alias #1488

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

Closed
matthew-dean opened this issue Jun 3, 2017 · 6 comments
Closed

router.getMatchedComponents() doesn't seem to match alias #1488

matthew-dean opened this issue Jun 3, 2017 · 6 comments

Comments

@matthew-dean
Copy link

Version

2.5.3

Reproduction link

https://codepen.io/matthewdean/pen/PjoeJw

Steps to reproduce

I have this router:

export function createRouter () {
  return new Router({
    mode: 'history',
    routes: [
      {
        path: '/', 
        component: Home,
        alias: '/index.html'
      },
      { 
        path: '/hello.html', 
        component: Hello
      }
    ]
  })
}

I'm using SSR to render Vue pages. However, when debugging, I've found that getMatchedComponents() only works with the main path, not the alias. So for this:

 // set server-side router's location
    router.push(context.url)

    // wait until router has resolved possible async components and hooks
    router.onReady(() => {
      const matchedComponents = router.getMatchedComponents()

... when context.url is '/' it renders my home component. When context.url is '/index.htmlthen matchedComponents is[undefined]`.

What is expected?

For getMatchedComponents() to match '/and/index.html`.

What is actually happening?

It's not doing that.

@matthew-dean
Copy link
Author

Note: the following works (some kind of internal logic bug?)

export function createRouter () {
  return new Router({
    mode: 'history',
    routes: [
      {
        path: '/index.html', 
        component: Home,
        alias: '/'
      },
      { 
        path: '/hello.html', 
        component: Hello
      }
    ]
  })
}

So when '/' is the alias of '/index.html' it seems to work, rather than the reverse.

@posva
Copy link
Member

posva commented Jun 3, 2017

You can provide a github repo as a repo, but make sure to boil it down, please 🙂

@LinusBorg
Copy link
Member

Seems like related to / duplicate of #1427

@posva
Copy link
Member

posva commented Jun 3, 2017

I thought so too, but it looks like he gets the opposite effect

@posva
Copy link
Member

posva commented Jun 20, 2017

Closing due to inactivity. Please open a new issue with a reference to this one if you can follow up with more information.

@posva posva closed this as completed Jun 20, 2017
@wilk
Copy link

wilk commented Jun 27, 2017

This bug has been fixed in version 2.6.0: 8e30c34

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants