最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How do I reload page on click of Vuetify Button? - Stack Overflow

programmeradmin2浏览0评论

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.

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.

Share Improve this question asked Jul 10, 2018 at 21:04 JeffJeff 1702 gold badges2 silver badges8 bronze badges 1
  • 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 props – Jeff Commented Jul 10, 2018 at 21:06
Add a comment  | 

1 Answer 1

Reset to default 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()
  }
}
发布评论

评论列表(0)

  1. 暂无评论