Skip to content
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

v-show on a component does not work when its template is just another component #1388

Closed
taras-puchko opened this issue Oct 5, 2015 · 5 comments

Comments

@taras-puchko
Copy link

Please see http://jsfiddle.net/5sH6A/176/

@Mat-Moo
Copy link

Mat-Moo commented Oct 5, 2015

v-show works on dom elements, you're replacing it so it can't use display none etc. Try v-if instead.

@taras-puchko
Copy link
Author

I'm replacing DOM here too, but it works in that case.

@yyx990803
Copy link
Member

A component that contains just another component makes the parent component a fragment instance, because the two components cannot share the same root node.

In general you should avoid components that only contain another component - why would you do that in the first place?

@taras-puchko
Copy link
Author

I have several object types that are displayed in a similar way. So my inner component handles presentation and several outer ones contain business logic specific for a particular type of object and pass data to the inner component instance.

@yyx990803
Copy link
Member

I'll add warning for this case in a future release. A simple solution is wrap your component with an outer element:

<div v-show="condition">
  <your-component></your-component>
</div>

Or use v-if instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants