1

Please take a look at the fiddle

https://jsfiddle.net/L3px7okf/

I want to reload the app when the same route (for example /foo) which you are currently on is clicked again because I need to reset the page state (yes, the correct way would be, actually, to reset the state, but the application code is a bit tricky thus I need a quick solution).

But I don't want to reload the app when I'm clicking /foo being on route /bar.

The problem is that VueRouter does nothing when the same link is clicked. Global (like beforeEach) and in-component (like beforeRouterEnter/beforeRouteLeave) hooks are not called. @onclick.native event handling doesn't help because when the handler is executed the route is already updated.

humkins
  • 9,635
  • 11
  • 57
  • 75

3 Answers3

0

I found this...https://stackoverflow.com/a/51170320/10039548

<router-view :key="$route.fullPath"></router-view>

Seems like they talk a bit about this issue here

Pwntastic
  • 433
  • 1
  • 8
  • 20
  • No, it is said "With the key, any change to the path will trigger a reload of the component with the new data". Thus, this still requires URL modification. – humkins Sep 17 '19 at 17:55
0
this.$router.go()

Can refresh the page on click..

Imtiyaz Shaikh
  • 425
  • 3
  • 7
0

Try using <a href="your route here"> I've used this and it's working just fine.

Adrian
  • 327
  • 1
  • 5
  • 13