zoukankan      html  css  js  c++  java
  • vue组件重新加载(刷新)

    vue组件重新加载(刷新)

    第一种方法:利用v-if控制router-view,在根组件APP.vue中实现一个刷新方法

    <template>
    <router-view v-if="isRouterAlive"/>
    </template>
    <script>
    export default {
     data () {
       return {
         isRouterAlive: true
       }
     },
     methods: {
       reload () {
         this.isRouterAlive = false
         this.$nextTick(() => (this.isRouterAlive = true))
       }   
     }
    }
    </script>
    
    然后其它任何想刷新自己的路由页面,都可以这样:
    this.reload()

     这种方法可以实现任意组件的刷新。

    第二种方法:路由替换

     // replace another route (with different component or a dead route) at first
    // 先进入一个空路由
    vm.$router.replace({
      path: '/_empty',
    })
    //then replace your route (with same component)
    vm.$router.replace({
      path: '/student/report',
      query: {
        'paperId':paperId
      }
    })

    转载自:https://blog.csdn.net/weixin_40054326/article/details/79384433

  • 相关阅读:
    虚函数******
    C++ 中的运算符重载********
    继承
    静态成员和成员函数
    类指针
    内联函数
    k8基础架构
    cobbler自动装机
    ens33-eth0
    PXE-自动装机配置
  • 原文地址:https://www.cnblogs.com/s313139232/p/9176820.html
Copyright © 2011-2022 走看看