zoukankan      html  css  js  c++  java
  • vue实现不刷新整个页面刷新数据

    vue 或者iview的框架里有个方法:需要刷线当前组件页面,不用刷线整个页面:网上有很多方法,但是不好使,都是刷新整个页面的方法,最终自己找到了方法,很好用:

    vue实现无刷新加载数据,使用的技术是依赖注入 关键字为provide inject
    在App.vue中

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

     然后在需要使用这个方法的的vue组件中注入这个方法

    data(){},
    inject:["reload"]
    
    
    //然后在你想要使用的地方 使用就可以了
    this.reload()

     
  • 相关阅读:
    合并果子
    在线最小值问题
    沙盒机制(sandBox)
    简单地址簿?
    浅拷贝、深拷贝
    NSFileManager、NSFileHandle
    NSDate、NSCalendar、NSDateFormatter
    归档
    类目、延展、协议
    动态类型
  • 原文地址:https://www.cnblogs.com/mahmud/p/11864145.html
Copyright © 2011-2022 走看看