vue中inject用法

2023-01-13 10:25:53

作用:刷新vue组件

使用方法:

在APP.vue中

 provide(){
            return {
                reload:this.reload
            }
        },
methods:{
            reload(){
                this.isRouterAlive = false
                this.$nextTick(function(){
                    this.isRouterAlive = true
                })
            }
        }

子组件中使用:

inject: ['reload'],

引入后直接this.reload()即可

  • 作者:斜影梧桐
  • 原文链接:https://blog.csdn.net/weixin_42582488/article/details/110404116
    更新时间:2023-01-13 10:25:53