Element: 表单验证的一个bug

Created on 20 Mar 2017  ·  5Comments  ·  Source: ElemeFE/element

当使用v-if使带有校验规则的输入项隐藏时,会使后面的输入项目校验失效,以下是触发条件:
1、被隐藏的输入项目使用了自定义校验规则
2、被隐藏的输入项的下一个输入项目没有设置校验

https://jsfiddle.net/ygo78r17/3/

_20170320094452
_20170320094500

另外上面的代码还有一个问题,当有隐藏时点重置表单,会报错
Uncaught TypeError: Cannot read property 'indexOf' of undefined

Most helpful comment

为每项添加 key 即可解决

All 5 comments

。。。

用 div 标签把它们包裹起来,或者直接在 div 标签上用 v-if ,不用 template
之前在使用 e-tag 的时候碰到过类似的问题

<template v-if="!defaultpwd" >
         <div>
  <el-form-item label="密码" prop="pass" >
    <el-input type="password" v-model="ruleForm2.pass" auto-complete="off"></el-input>
  </el-form-item>
  <el-form-item label="确认密码" prop="checkPass" >
    <el-input type="password" v-model="ruleForm2.checkPass" auto-complete="off"></el-input>
  </el-form-item>
           </div>
  </template>

Hello, this issue has been closed because it does not conform to our issue requirements. Please submit issues with issue-generator. More info can be found in #3693.

我本地也遇到了这个问题。尤其是属性是多级的时候。一打包到线上就完蛋
image

image

为每项添加 key 即可解决

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gangyeona picture gangyeona  ·  58Comments

ivan403704409 picture ivan403704409  ·  36Comments

subo-romens picture subo-romens  ·  30Comments

istobran picture istobran  ·  33Comments

Leopoldthecoder picture Leopoldthecoder  ·  52Comments