How do I reload page on click of Vuetify Button?
Asked Answered
F

1

8

I need to refresh the current page when a user clicks the refresh button. I'm using Vuetify to generate the button.

<v-btn fab dark>
     <v-icon dark>refresh</v-icon>
</v-btn>

I know in place of the router I can specify <v-btn fab dark to="myDesiredPath" but I need to refresh whatever route the user is currently on.

I know in vanilla js I can use location.reload(), but I don't know how to feed that to the button on the user's click.

Femi answered 10/7, 2018 at 21:4 Comment(1)
Update: I used <v-button fab dark onclick="location.reload(true)> which works but it causes a problem with some routes not rendering with their propsFemi
A
18

you can just create a method in Vue that runs the vanilla JS and then run that method @click of the v-btn.

methods: {
  reloadPage(){
    window.location.reload()
  }
}
Aphelion answered 10/7, 2018 at 21:8 Comment(2)
This works but it causes a problem with some routes not rendering with their props. The page needs to reload on the route, but it also needs to keep the properties passed by the routeFemi
method is not necesssaaryDaina

© 2022 - 2024 — McMap. All rights reserved.