[Vuejs]-VueJS goBack from Dynamic Route

0👍

Maybe you uses replace option on your anchor.

please check out your tag has this property

<router-link :to="..." **replace**>

0👍

Then call $router.go(-1) and that direct me to / instead of /items/iphone5

go method is based on history API

go(-1) returns to previous entry stored in the current history entry

I go / then /items/iphone5 then /items/phone6

You have to inspect whether the history entry counts for your route or try using history mode

vue router default mode is hash.

const router = new VueRouter({
  mode: 'history',
  routes: [...]
})

Read docs for more info [Read caveats in the last and Server Side Rendering in first place if you have some time]

Leave a comment