Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upThe child component clipped by v-if was rendered twice #10860
Closed
Comments
This comment has been minimized.
This comment has been minimized.
I just tried to replace |
This comment has been minimized.
This comment has been minimized.
Duplicate of #10836 |
This comment has been minimized.
This comment has been minimized.
I know the difference between v-show and v-if, I also know that adding a key will solve the problem. But why changing the initial values of a and b will have different results when there is no key? |
This comment has been minimized.
This comment has been minimized.
My English is not very good, so I cannot elaborate in detail. However, you can look at the Diff algorithm of vue's virtual DOM. Key is used as a unique identifier, and there is a difference between having and not having |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Version
2.5.22
Reproduction link
https://codesandbox.io/embed/vue-template-b6c06?fontsize=14&hidenavigation=1&theme=dark
Steps to reproduce
When the initial value of
a
is equal totrue
andb
is equal tofalse
, the child component was created twice.When the initial value of
a
is equal tofalse
andb
is equal totrue
, the child component was created once.When the initial value of
a
andb
are same, the child component was created twice.What is expected?
The child component is created the same number of times in different cases
What is actually happening?
The child component is created the different number of times in different cases