vShow and vIf has different status
Vue version
latest
Link to minimal reproduction
Steps to reproduce
trigger button
What is expected?
component TestIf and component TestShow all can switch display status
What is actually happening?
only TestIf can switch display status
System Info
No response
Any additional comments?
I know the reason because the testShow component does not have a common parent element. In the source code, vShow sets the display attribute for style. So my code doesn't work, https://github.com/vuejs/core/blob/fc772dbf7398e8ce961025556594b4a7d3f64871/packages/runtime-dom/src/directives/vShow.ts#L27-L35 but I'm curious is there no other way to achieve this functionality? When my child component does not have a common parent element
You can use a custom prop that sets v-show on all elements in the child, or wrap the component in another element in the parent.