How to destroy a VueJS component that is being cached by

前端 未结 4 1527
天涯浪人
天涯浪人 2021-01-13 17:16

I have a Vue component that\'s kept alive using Vue\'s element for caching purposes. However, the problem I am having right now is that once I sign out of one account and c

4条回答
  •  离开以前
    2021-01-13 18:10

    for anyone looking for a solution that destroys the cache

    in my case I was using this in a logout route, replace router.app with this.$root in Vue instances and the $children index/nesting may differ for your app

    setTimeout(() => {
        var d = [];
        for(var vm of router.app.$children[0].$children) {
            if(vm._inactive === true)
                d.push(vm);
        }
        for(var vm of d) {
            vm.$destroy();
        }
    });
    

提交回复
热议问题