0๐
โ
I found a way as a workaround to mimic the behaviour of vue 2.x app mounting by using fragments.
import { createApp, h } from 'vue';
import ContentApp from '@js/ContentApp';
const fragment = document.createDocumentFragment();
const targetEl = document.getElementById('vueContent');
const app = createApp({
render: () => h(ContentApp, { ... }),
});
app.use(store);
// Temporarily mount the vue app on the fragment
app.mount(fragment);
// Now replace the target element with the fragment that has the app
targetEl.parentNode.replaceChild(fragment, targetEl);
๐คOlie Cape
1๐
According to Vue 3 Migration Guide: Mounted application does not replace the element
While in Vue 2 the HTML element selector is replaced, on Vue 3 the mount function will create content inside the selector.
๐คHans Felix Ramos
Source:stackexchange.com