zoukankan      html  css  js  c++  java
  • vue实现某个页面强制刷新router-view

    1、首先需要修改App.vue

    <template>
      <div id="app">
        <router-view v-if="isRouterAlive" />
      </div>
    </template>
    
    <script>
    export default {
      name: "App",
      provide() {
        return {
          reload: this.reload,
        };
      },
      data() {
        return {
          isRouterAlive: true,
        };
      },
      methods: {
        reload() {
          this.isRouterAlive = false;
          this.$nextTick(() => {
            this.isRouterAlive = true;
          });
        },
      },
    };
    </script>

    2. 到需要刷新的页面进行引用,使用inject导入引用reload,然后直接调用即可

    <template>
      <div></div>
    </template>
    
    <script>
    export default {
      inject: ['reload'],
      data() {
        return {},
      },
      created() {
        this.reload();
      },
      methods: {},
    }
    </script>
  • 相关阅读:
    学习笔记::有上下界的网络流
    zoj2314
    bzoj3261
    bzoj 1898
    bzoj4009
    bzoj4033
    bzoj3389
    bzoj2427
    uva 11825
    交换A与B值的四种方法
  • 原文地址:https://www.cnblogs.com/wangjae/p/15330207.html
Copyright © 2011-2022 走看看