2020-02-17 用provide / inject解决vu

2020-02-17  本文已影响0人  Rockage

要点:

  1. app.vue
//模板:
   <router-view  v-if="isRouterAlive"></router-view>
//Vue代码:
export default {
  name: "App",
data() {
  return {
    isRouterAlive: true
  };
},
provide() {
  return {
    reload: this.reload
  };
},
methods: {
  reload: function() {
    this.isRouterAlive = false;
    this.$nextTick(function() {
      this.isRouterAlive = true;
    });
  },
};
上一篇下一篇

猜你喜欢

热点阅读