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

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 }
});

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

相关文章:

  • 1970-01-01
  • 2021-12-05
  • 2021-12-20
  • 2021-08-15
  • 2022-12-23
  • 2021-05-30
  • 2021-12-22
猜你喜欢
  • 2021-05-16
相关资源
相似解决方案