Element: 使用 v-if 切换多个含有 table 组件的 dom 显示时, table组件渲染错乱

Created on 10 Nov 2016  ·  6Comments  ·  Source: ElemeFE/element

ElementUI version

1.0.0-rc.9

OS/Browers version

macOS/Chrome 54

Vue version

2.0.3

Reproduction Link

https://jsfiddle.net/5v6nc9cw/

Steps to reproduce

点击测试按钮,会由 card 组件 A 切换到 card 组件 B(这两个组件里各有一个 table 组件)

What is Expected?

card 组件 B 中的 table 第二列的内容应为一个自定义模板,是个 input 组件

What is actually happening?

把 card 组件 A 中的 table 第二列的内容给渲染到 card 组件 B 中的 table 去了。

question

Most helpful comment

@jin5354 vue2 本身的 Virtual Dom 实现机制的问题,增加一个 key 属性就可以解决。https://jsfiddle.net/5v6nc9cw/1/

All 6 comments

v-if 会出现这个问题, v-show 则不会出现这个问题。

我很多地方都发现v-if很奇怪。。。

甚至有时候用v-if, v-model会绑定不上

@reverland 确实是这样,最终我只得用子路由来避开问题

看起来是目前 tabs 的 bug @baiyaaaaa

@jin5354 vue2 本身的 Virtual Dom 实现机制的问题,增加一个 key 属性就可以解决。https://jsfiddle.net/5v6nc9cw/1/

@furybean 果然如此 谢谢 帮大忙了

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Kingwl picture Kingwl  ·  3Comments

mochenxm picture mochenxm  ·  3Comments

zhguokai picture zhguokai  ·  3Comments

gengxuelei picture gengxuelei  ·  3Comments

fscardua picture fscardua  ·  3Comments