Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vue router: go up one (variable) level

seems nobody had this question before...? (or i just don't know the right words for it :D )

i want to have a very basic heading on every page of my app, which allows the user to go "up". simple as that.

example: user is on page.com/users/browse/, clicks on the heading, gets navigated to page.com/users/, clicks again, gets navigated to page.com. nothing more. it just has to be variable, so i can put it in a component and have it just work everywhere

how can i do that? i tried vue.$route, but there is only a string of the complete url. is there any convenient way to do it? or do i HAVE to split the url by / and build the route myself?

thanks :)

like image 517
devman Avatar asked Dec 06 '18 13:12

devman


2 Answers

Try using this: this.$router.replace("./");

I don't know how it is working though. The single dot(./) will go up one path and double dots(../) will go up 2 paths!

like image 54
theHarsh Avatar answered Sep 28 '22 08:09

theHarsh


This functionality has a name "Breadcrumbs". Check this: 1, 2, 3 or look for this in your framework.

like image 36
Maxim Avatar answered Sep 28 '22 08:09

Maxim