Vue-router: Is it possible change url but dont render component by vue-router now?

Created on 6 Dec 2016  路  3Comments  路  Source: vuejs/vue-router

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

Most helpful comment

It does not...

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

Thx

All 3 comments

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

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

It does not...

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

Thx

Appears to be duplicate of https://github.com/vuejs/vue-router/issues/703, please reopen if I'm wrong.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

marcvdm picture marcvdm  路  3Comments

kerlor picture kerlor  路  3Comments

Atinux picture Atinux  路  3Comments

rr326 picture rr326  路  3Comments

baijunjie picture baijunjie  路  3Comments