Vue3 中未发出 beforeDestroy 生命周期钩子 [英] Lifecycle hook beforeDestroy is not emitted in Vue3
本文介绍了Vue3 中未发出 beforeDestroy 生命周期钩子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用vue3 beta 18,发现当我删除一个由v-for中的动态组件渲染的组件时,没有发出beforeDestroy.
I use vue3 beta 18, found that beforeDestroy is not emitted when I remove a component which is rendered by dynamic component in v-for.
既没有被停用,也没有被销毁.
Neither are deactivated, destroyed.
当我从集合windows"中删除该组件时,该组件消失了".
The component is "disappeared", when I remove it from the collection "windows".
<template>
component(v-for="ww in windows" :key="ww.$id" :is="ww.component" v-bind="ww.props")
</template>
推荐答案
在 Vue 3 中,beforeDestroy 和destroy hooks 被替换为 beforeUnmount 和 unmounted https://v3.vuejs.org/api/options-lifecycle-hooks.html#beforeunmount
In Vue 3 beforeDestroy and destroyed hooks are replaced with beforeUnmount and unmounted https://v3.vuejs.org/api/options-lifecycle-hooks.html#beforeunmount
这篇关于Vue3 中未发出 beforeDestroy 生命周期钩子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文