John Moore
John Moore

Reputation: 7129

router-link replace with vue-router?

With the router-link tag with vue-router, "Setting replace prop will call router.replace() instead of router.push() when clicked, so the navigation will not leave a history record", according to the docs. But this doesn't seem to be happening for me, so I think I must be misunderstanding something. I have a navigation menu in my SPA and the router-link in each menu item has a replace prop. Yet when I click on each menu item in turn, it clearly does add to the history, in that the back button takes me back to the previous item, and I can actually see in the Firefox history the list of URLs being added to. What am I doing wrong?

Upvotes: 4

Views: 11652

Answers (1)

chengjun liu
chengjun liu

Reputation: 136

use <router-link :to='{path:'/test'}' replace> Go <router-link> in component "history",after clicking "Go", the url is "..../test",the "history" component's url is still in url's history list. but if you click back button of browser, '.../history' is disappeared .[Vue.2]

Upvotes: 12

Related Questions