-
-
Notifications
You must be signed in to change notification settings - Fork 8.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot mount an app within an app #5661
Comments
Demo with x6 library:Reproduction linkhttps://stackblitz.com/edit/vitejs-vite-nghwu9?file=README.md Steps to reproduce
What is expected?Remove all the two custom nodes What is actually happening?Only remove one node |
You cannot mount an app within an app, use a component instead or make sure you manually add an element that isn't handled by Vue |
@posva Thanks for your reply. I know it is the best practice not to mount an app within an app. Maybe the sfc reproduction link is obfuscated. In this https://stackblitz.com/edit/vitejs-vite-nghwu9 demo, the editable svg area is an element not controlled by vue. x6 library can be using create an svg node using vue component with The key point is when the child nodes of the fragment container doesn't exist, unmounting the fragment instance will cause the error. Some complex apps may be consisting with multi app instance, fake code below, <head>
<!-- some code -->
</head>
<body>
<div id="subapp1"></div>
<div id="subapp2"></div>
<script>
const subApp1 = createApp({/* fragment component*/});
const subApp2 = createApp({});
subApp1.mount('#subapp1');
subApp2.mount('#subapp2');
document.getElementById('subapp1').innerHTML = '';
subApp1.unmount();
</script>
</body> Vue will throw the error on calling But it would be confused when the application is complicated. Especially using some third-party libraries that use |
You are not supposed to manually manipulate the HTML that is handled by Vue either. You just need to move the html clear after the unmount like this |
Version
3.2.31
Reproduction link
sfc.vuejs.org/
Steps to reproduce
Click the 'unmount app' button
The error message will show in the Developer Tools Console
What is expected?
No error on
app.unmount()
when the fragment dom content is not existWhat is actually happening?
There is an error on
app.unmount()
when the fragment dom content is not existCombine usages of x6 and AntdVue
Maybe this error will occur in some other scenarios when
app.unmount()
The text was updated successfully, but these errors were encountered: