Closed xuncanzhe closed 1 week ago
this is the expected behavior. see Playground, where is a warning.
Have you tried changing it to v-show="false"? It still shows 1 2. Is this expected?
[Vue warn]: Runtime directive used on component with non-element root node. The directives will not function as intended.
The directives will not function as intended. no matter whether true
or false
.
thanks! Does it mean that there can only be one first-level element under template ? In the case of multiple, v-show will no longer work?
thanks! Does it mean that there can only be one first-level element under template ? In the case of multiple, v-show will no longer work?
Correct.
Vue version
3.5.12
Link to minimal reproduction
https://stackblitz.com/edit/vitejs-vite-toxnby?file=src%2Fcomponents%2FHelloWorld.vue
Steps to reproduce
Just look at the display content on the right. It works fine when using v-if or a single first-level element
What is expected?
Only 0 is displayed.
What is actually happening?
display: 0 12
System Info
No response
Any additional comments?
No response