zoukankan      html  css  js  c++  java
  • vue全局刷新

    想在app.vue触发

    • 在全局组件注册一个方法,该方法控制router-view的显示与否,可接受参数.
    <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: false
        }
      },
      methods: {
        reload(Boolean) {
          this.isRouterAlive = Boolean
        }
      }
    }
    </script>
    

    以上写好,如何调用?

    • 在子其它页面里将注册的导入
    export default {
    inject: ['reload'],
    mounted(){
    this.reload(false);
    }
    }
    
  • 相关阅读:
    【POJ2311】Cutting Game-SG博弈
    deleted
    deleted
    deleted
    deleted
    deleted
    deleted
    deleted
    deleted
    deleted
  • 原文地址:https://www.cnblogs.com/1748sb/p/13967650.html
Copyright © 2011-2022 走看看