[英]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.导航到该页面时,我想刷新页面(与在 Mac OS 上单击 Command+R 的效果相同)。
For example:例如:
I have "abc.com/login" for the Login page which will navigate to "abc.com/dashboard" for Dashboard after login successfully.我的登录页面有“abc.com/login”,登录成功后将导航到仪表板的“abc.com/dashboard”。 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. “刷新”是指在浏览器中单击 Command+R 的意思。
this.$router.go()
不带参数将重新加载页面。
You can use vue built-in forceUpdate
function, like this:你可以使用 vue 内置的forceUpdate
函数,像这样:
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.将true
传递给 reload 函数将强制页面从服务器重新加载。 Alternatively, pass false
to reload from cache.或者,传递false
以从缓存中重新加载。 This is vanilla javascript so it is not a vueJS only solution.这是 vanilla javascript,所以它不是 vueJS 唯一的解决方案。
You can use something like this你可以使用这样的东西
window.location.href = "/dashboard?key=" + Math.random()
Instead of Math.random() something else can be used if required如果需要,可以使用其他东西代替 Math.random()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.