inject Refresh

1, modify App.vue

  <template>

    <div id="app">

      <router-view v-if="isRouterAlive"></router-view>

    </div>

  </template>

  <script>

  export default {

    name: "app",

    provide() {

      return {

        reload: this.reload

      }

    },

    data() {

      return {

        isRouterAlive: true

      };

    },

    methods: {

      reload() {

        this.isRouterAlive = false;

        this.$nextTick(function() {

          this.isRouterAlive = true;

        })

      }

    }

  }

  </script>

2, a reference to the need to refresh the page

  export default {

    inject: ["reload"],

    data() {

      return {

      }

    },

    methods: {

      //transfer

      this.reload()

    }

  }

Guess you like

Origin www.cnblogs.com/zjxiang008/p/12167961.html