简体   繁体   中英

How to completely refresh a page right when navigating to it?

I would like to refresh a page (same effect as click Command+R on Mac OS) when navigating to that page.

For example:

I have "abc.com/login" for the Login page which will navigate to "abc.com/dashboard" for Dashboard after login successfully. At the moment, it navigates to the Dashboard without completely refresh the whole page.

I would like it to completely refresh everything. By "refresh", I mean it is the same as clicking Command+R on the browser.

this.$router.go()不带参数将重新加载页面。

You can use vue built-in forceUpdate function, like this:

vm.$forceUpdate()

or if it's inside the component, you can use

this.$forceUpdate();

References:

Try:

window.location.reload(true);

Passing true to the reload function will force the page to reload from the server. Alternatively, pass false to reload from cache. This is vanilla javascript so it is not a vueJS only solution.

You can use something like this

window.location.href = "/dashboard?key=" + Math.random()

Instead of Math.random() something else can be used if required

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM