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