vue如何刷新当前页


项目中会有需求刷新当前整个页面,用路由直接刷新的话会有一个白色闪屏出现,怎么解决这个问题呢?

1、首先 我们需要创建一个空白页面

<template></template>
<script>
export default {
  name: 'reload',
  props: {},
  beforeCreate() {
      const { query } = this.$route;
      const { path } = query;
      this.$router.replace({
          path: path
      });
  },
  render(h) {
    return h();
  }
}
</script>

2、在需要用到刷新的页面直接调用

const { fullPath } = this.$route;
this.$router.replace({
    path: "/redirect",
    query: { path: fullPath }
});

注:如果还有其他解决方案 欢迎留言补充交流哦~


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM