vue/no-deprecated-destroyed-lifecycle
禁止使用已废弃的destroyed和beforeDestroy生命周期钩子(Vue.js 3.0.0+)
为什么
在Vue.js 3.0.0+中,destroyed和beforeDestroy生命周期钩子已被废弃。
建议
使用beforeUnmount和unmounted替代。
错误示例
vue
<script>
export default {
beforeDestroy() {},
destroyed() {}
};
</script><script>
export default {
beforeDestroy() {},
destroyed() {}
};
</script>正确示例
vue
<script>
export default {
beforeMount() {},
mounted() {},
beforeUnmount() {},
unmounted() {}
};
</script><script>
export default {
beforeMount() {},
mounted() {},
beforeUnmount() {},
unmounted() {}
};
</script>