I'm pretty sure that your attempt so solve a problem in a way that it should not be solve, or that you use vue in the wrong way.
But to you problem, when you execute this code:
if (app) {
app.$destroy();
}
Then the documentation state:
Completely destroy a vm. Clean up its connections with other existing vms, unbind all its directives, turn off all event listeners.
So they don't say that the element to wich the vue app is attached to has to or will change. If you want to clean up the DOM then you need to delete the content manually.
After app.$destroy() the app variable will still hold the destroyed vue instance (app wont be magically unset). So another execution of the code will not trigger the else block.
You also have to set app to something that evaluates to falsy.
if (app) {
app.$destroy();
app = undefined;
}
Now app is undefined so at the next time the if statment is evaluated, the else block would be evaluated and a new instance is created.
appis set thenapp.$destroy()will be called, butapp = new Vuenot because it is in theelseblock, so it won't be recreated (app.$destroywould not magically empty the variableapp). But way do you want to to it this way, instead of updating the data?