Open ghost opened 7 years ago
主要是你那个发生改变的组件和 v-if
里的东西完全一样,diff 的时候难免会判断错误,但最起码也可以保持渲染出来的结果是一样的。临时解决办法就是在这些标签上加一些不一样的 attribute,就立刻工作正常了。
Translate into English:
Temporarily you can easily change:
<div><custom-component ref="componentPlugin"></custom-component></div>
into:
<div marked><custom-component ref="componentPlugin"></custom-component></div>
to avoid the re-render of the custom component in the middle.
Because the v-if
component and the element above is all the same tag + without any props/attrs. So It's hard to the detect update details very exactly. But you can add special attribute to solve this.
Thanks.
For now you can use a key
on the div to mark it: https://jsfiddle.net/50wL7mdz/63293/
However this can be improved for sure.
谢谢
看不懂哟
key is importatnt
I'll take a stab at this.
Version
2.3.3
Reproduction link
https://jsfiddle.net/vitorDeng/50wL7mdz/63147/
Steps to reproduce
打开浏览器控制台,点击Run
What is expected?
其他v-if的元素不应该影响互不相干的组件
What is actually happening?
同级下,若前后使用了与包裹组件的元素一样的,并使用了v-if指令,则v-if指令会影响该组件不断创建和销毁