方式一:
location.reload()
方式二:
在需要刷新的地方直接使用vue的路由跳转
this.$router.go(0)
方式三:(推荐此方式,因为此方法不会出现短暂闪烁的空白页)
第一步:App.vue页面
<template><div id="app"><div class="container">//一定要加v-if,否则无法实现<router-view v-if="isRouterAlive"></router-view></div></div></template><script>export default {name: 'App',provide () { //父组件中通过provide来提供变量,在子组件中通过inject来注入变量return {reload: this.reload}},data(){return{isRouterAlive: true}},methods:{reload(){this.isRouterAlive = false;this.$nextTick(function(){this.isRouterAlive = true;})}}}</script>
第二步:在需要刷新的页面导入并使用
export default {inject:['reload'],//需要刷新的地方引入即可,比如下面的方法methods:{testHandler(){this.reload();}}}
如果觉得《vue刷新当前页面且页面不闪烁》对你有帮助,请点赞、收藏,并留下你的观点哦!