zoukankan      html  css  js  c++  java
  • Vue删除数据成功后如何刷新表格数据

    刷新表格数据的方法:


    1、this.$router.go(0)
    2、location.reload()
    3、跳转空白页再跳回原页面
    4、控制的显示隐藏(最实用的方法)


    刷新表格数据的方法:
    1、this.$router.go(0)
    这种方法页面会一瞬间的白屏,体验不是很好,虽然只是一行代码的事

    2、location.reload()
    这种也是一样,画面一闪,效果总不是很好

    3、跳转空白页再跳回原页面
    在需要页面刷新的地方写上:this.$router.push(’/emptyPage’),跳转到一个空白页。在emptyPage.vue里beforeRouteEnter 钩子里控制页面跳转,从而达到刷新的效果

    beforeRouteEnter (to, from, next) {
    next(vm => {
    vm.$router.replace(from.path)
    })
    }

    这种画面虽不会一闪,但是能看见路由快速变化

    4、控制的显示隐藏(最实用的方法)
    在App.vue中写如下代码

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

    然后在需要刷新的页面引入依赖:inject: [‘reload’],


    在需要执行的地方直接调用方法即可:this.reload()

     

    ————————————————
    版权声明:本文为CSDN博主「星空浩荡」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
    原文链接:https://blog.csdn.net/weixin_45139342/article/details/107976362

  • 相关阅读:
    一点点深夜感慨(还有居家学习日常)
    区间dp 矩阵连乘
    logstash grok match 对等于号,和中括号做筛选
    grok内置的默认类型有很多种,查看所有默认类型
    python开发技术要求
    django--models操作--备注
    django程序--settings.py文件备注
    django-admin 命令备注
    官网提供jumpserver安装文档--复盘 CentOS 7 安装文档
    安装jumpserver,提示错误
  • 原文地址:https://www.cnblogs.com/Ao-min/p/14857645.html
Copyright © 2011-2022 走看看