I am facing a challenge with destroying and re-creating the root application component. Below is my template structure:
<div id="app">
{{ num }}
</div>
Here is the code I have implemented:
if (app) {
app.$destroy();
} else {
app = new Vue(Object.assign({
el: '#app',
}, { data: { num: Math.random() } }))
}
When this code runs on button click, it fails to properly clean the template and refresh the data being passed. Can you help me understand why this might be happening?