Iview: Form动态添加的rules无法触发blur校验

Created on 17 Apr 2017  ·  3Comments  ·  Source: iview/iview



iView 版本号

2.0.0-rc.10

操作系统/浏览器 版本号

macOS/Chrome 59

Vue 版本号

2.2.6

能够复现问题的在线示例(bug 相关不提供在线示例将直接 close)

http://jsbin.com/nepicod/7/edit?html,js,console,output

复现步骤

问题现象,以及你期望的结果是怎样的?

Form初始化的时候不设置rules,而是后期动态添加(异步请求或者其他方式),这些规则即使设置了blur触发也没有效果,但是整个Form执行validate是可以校验的

你估计可能的原因是什么(选填)?

FormItem是在mounted的时候调用this.getRules()获取父组件Form中的所有规则,然后执行分别执行

this.$on('on-form-blur', this.onFieldBlur);

但是,动态添加或者异步添加rules的时候,上面的代码不会被执行

need to optimize

All 3 comments

好问题,动态的规则还是很多的,否则太不灵活了。希望尽快解决

使用 rule 数据

以下可暂时解决此问题:
1.找到node_modules中iview的components目录下的form.vue组件
目录:node_modules=>ivew=>src=>components=>form=>form.vue
2.注释form.vue文件watch下面监听的rules
image
3.也可以把form.vue组件修改后拷贝到项目中修改
@lvqingan @icarusion

Was this page helpful?
0 / 5 - 0 ratings

Related issues

agileago picture agileago  ·  3Comments

kengqiangxia picture kengqiangxia  ·  3Comments

WangLei1993 picture WangLei1993  ·  3Comments

lichinlichin picture lichinlichin  ·  3Comments

StanleyYechen picture StanleyYechen  ·  3Comments