Search code examples
vue.jsvuejs3vue-component

How to unmount a Vue3 component in script setup


For example, I have a component like this.

<template>
    <el-card @click='destroyCard'>
       ......
    </el-card>
</template>
<script setup>
......
let destroyCard = () => {
    ......
}
onUnmounted(() => {
    console.log('destroyed')
})
</script>

I know I can emit a methon to Parent component and destroy the component.But I want to destroy/unmount this component from it self, is it possible?


Solution

  • Can't vue components can't commit suicide that's true in either angular or react!!