Skip to content

Is it possible change url but dont render component by vue-router now? #988

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
achen224 opened this issue Dec 6, 2016 · 3 comments
Closed

Comments

@achen224
Copy link

achen224 commented Dec 6, 2016

I have 2 routes like:

{ path: '/gallery', component: require('components/A') },
{ path: '/gallery/:id', component: require('components/B') },

when user go /gallery/:id from outside, it will render component B
but when user go form my webside(like /gallery -> /gallery/:id)
I want change url but render component in lightbox component not router-view

I use like below now

{
      path: '/gallery/:id',
      component: require('components/B'),
      beforeEnter: (to, from, next) => {
        if (from.matched.length) {
          history.pushState({}, null, to.path)
        } else {
          next()
        }
      }
}

is it possible change url but dont render component by vue-router ?
just like backbone router trigger in router-link, router.push & router.replace

Thx

@JounQin
Copy link
Contributor

JounQin commented Dec 6, 2016

https://router.vuejs.org/en/essentials/navigation.html

router.replace(location) should work, doesn't it?

@achen224
Copy link
Author

achen224 commented Dec 6, 2016

It does not...

router.replace just like push...but replace history
it will render component in render-view

Thx

@simplesmiler
Copy link
Member

simplesmiler commented Dec 6, 2016

Appears to be duplicate of #703, please reopen if I'm wrong.

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

No branches or pull requests

3 participants