Skip to content

v-if loses data context #489

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
tim-smart opened this issue Oct 14, 2014 · 3 comments
Closed

v-if loses data context #489

tim-smart opened this issue Oct 14, 2014 · 3 comments

Comments

@tim-smart
Copy link

This works as expected:

<span v-text="$data | json"></span>

But if I introduce a v-if directive:

<span v-if="someTrueValue" v-text="$data | json"></span>

I just get a empty object as the text.

@yyx990803
Copy link
Member

A simple example seems to work correctly, so I suspect it's something else... are you using a component with the v-if as well?

@tim-smart
Copy link
Author

Here is a demo: http://codepen.io/anon/pen/abJys

@yyx990803
Copy link
Member

Oh ok, thought you are referring to a property instead of $data. Yeah the caveat here is that v-if creates an anonymous wrapper instance around its content, it inherits all normal properties but its $data is an empty object. I'll probably rework that part later since the anonymous instance isn't ideal anyway.

yyx990803 added a commit that referenced this issue Oct 15, 2014
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants