简体   繁体   English

导航到页面时如何完全刷新页面?

[英]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.

相关问题 如何在导航到另一个页面但不刷新时清除sessionStorage? - How to clear sessionStorage when navigating to another page but not on refresh? 如何在页面未完全加载时刷新javascript中的div内容? - How to refresh a div content in javascript when the page has not loaded completely? 如何在页面完全加载后立即自动刷新一次而不更改或在URL中添加字符串? - How to refresh a page once automatically right after it loads completely without changing or adding a string in the URL? 导航时如何在不刷新页面的情况下将用户重新定位到另一页面的内容? - How do I relocate the user to contents of another page without page refresh when navigating? 在导航到另一个页面之前,如何确保功能完全执行? - How to ensure that a function is executed completely, before navigating to another page? 使用 Vue 路由器导航时防止刷新索引页面 - prevent refresh of index page when navigating away using Vue router 在页面之间导航时如何避免刷新布局视图 - How to avoid refresh of layout view when navigating between pages HTML 元素在导航到页面时消失,在页面刷新时重新出现 - HTML elements disappear when navigating to the page, re-appear on page refresh 当我刷新页面时,如何使计数器始终具有正确的数字 - How to make counter which always will have right number when iI refresh a page 导航到新页面时如何清除上一页? - How do I clear the previous page when navigating to a new page?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM