JSFiddle - React, Tailwind, and code Playground
HTML
<div id="app">
<my-comp v-if="destroyComponent"></my-comp>
<button @click="destroyComp">destroy component</button>
</div>
JavaScript
var MyComponent = {
template:`<div id="app">
<h2>This is a component</h2>
</div>`,
destroyed(){
alert('component destroyed');
}
}
new Vue({
data(){
return{
destroyComponent:true
}
},
components:{
'my-comp': MyComponent
},
methods:{
destroyComp(){
this.destroyComponent = false;
}
}
}).$mount('#app');