Element: [Bug Report] verifies failure when judging Form form through V-IF logic.

Created on 18 Oct 2018  ·  5Comments  ·  Source: ElemeFE/element

Element UI version

0.1.0

OS/Browsers version

Mac/Google Chrome 69

Vue version

2.5.17

Reproduction Link

https://jsfiddle.net/rztdvn1e/

Steps to reproduce

1.为el-form-item添加prop验证器;
2.通过v-if表达式逻辑判断el-form-item是否显示;
3.当v-if为真时,显示el-form-item;
4.验证器不起作用;

What is Expected?

通过v-if逻辑判断的时候,希望条件为真时,验证器依然起效;

What is actually happening?

通过v-if逻辑判断的时候,希望条件为真时,验证器不起效;

Most helpful comment

还是元素复用的问题, display为true的时候上面的el-form-item复用了原来的, 并没有重新从头渲染, 所以prop也没传递进去. 设置不同的key就可以.
https://jsfiddle.net/rztdvn1e/1/
参考用 key 管理可复用的元素

All 5 comments

Translation of this issue:

Element UI version
0.1.0

OS/Browsers version
Mac/Google Chrome 69

Vue version
2.5.17

Reproduction Link
https://jsfiddle.net/rztdvn1e/

Steps to reproduce

  1. add prop validator to el-form-item.
  1. judge whether el-form-item is displayed by V-IF expression logic.
  2. when V-IF is true, display el-form-item;

  3. verifier does not work.
    What is Expected?

When V-IF logic is used, the verifier still works when the desired condition is true.
What is actually happening?

When the V-IF logic is judged, the verifier will not work when the desired condition is true.

页面地址中,需要点击【即时配送】的switch进行切换条件真假

还是元素复用的问题, display为true的时候上面的el-form-item复用了原来的, 并没有重新从头渲染, 所以prop也没传递进去. 设置不同的key就可以.
https://jsfiddle.net/rztdvn1e/1/
参考用 key 管理可复用的元素

@coffeeyen 谢谢你,确实是这样的,第一次遇到这个问题。

@coffeeyen 的方案可行。👍
看到你在许多 issue 下回答问题,如果对维护 Element 感兴趣,可以联系我。

Was this page helpful?
0 / 5 - 0 ratings

Related issues

yuchonghua picture yuchonghua  ·  3Comments

akaylh picture akaylh  ·  3Comments

dbskccc picture dbskccc  ·  3Comments

makunsusu picture makunsusu  ·  3Comments

EdenSpark picture EdenSpark  ·  3Comments