Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 721
John Moore Avatar asked Sep 13 '25 02:09

John Moore


1 Answers

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]

like image 162
chengjun liu Avatar answered Sep 14 '25 16:09

chengjun liu