2.4.0
macOS / Chrome 67.0.3396.62
2.5.16
https://jsfiddle.net/64wjqbLc/5/
首先点击「校验」按钮触发form的validate方法,如果此时表单数据如果为空,会显示请选择和请填写的提示。
然后点击「设置为浙江」按钮修改表单中el-select和el-input绑定的值,这时因为el-input因为值被修改所以再次触发了校验,因为符合校验规则所以错误提示消失了,但是el-select却没有触发校验规则,如果此时在点击「校验」按钮则再次触发表单所有校验el-select的错误提示也消失。
因为在实际开发中经常会有动态修改el-select值的情况,所以希望el-select 也可以像 el-input一样在动态修改的时候可以触发校验。
el-select 在动态修改的时候没有触发校验。
Translation of this issue:
Element UI version
2.4.0
OS/Browsers version
MacOS / Chrome 67.0.3396.62
Vue version
2.5.16
Reproduction Link
https://jsfiddle.net/64wjqbLc/5/
Steps to reproduce
First click the "check" button to trigger the validate method of form. If the form data is empty at this time, the prompt that you choose and fill in will be displayed.
Then click the "set to Zhejiang" button to modify the value of el-select and el-input binding in the form, when the el-input is changed because the value is modified so that the check is triggered again, because the error prompt disappears, but the el-select does not trigger the check rule, if at this time the check button is clicked. Triggering the form again, the error prompt for all check el-select is also gone.
What is Expected?
Because there are often dynamic changes to el-select values in actual development, it is hoped that el-select can also trigger checkout as el-input is dynamically modified.
What is actually happening?
El-select did not trigger validation when changing dynamically.
This is not a bug. But can be a feature request for a public method.
I am guessing; when you clear the select value it doesn't know if the value changed. Because it is value-key pair. I made a few update to your example. If you make it clearable and clear it, it works. I think clear method should be exposed.
emitChange inside select component.
This indeed is something we should work on. We definitely don't want this kind of inconsistent behavior.
@atilkan Looks like it doesn't work for me.
And I don't just need to check the form when it is empty, but I need to check the form every time I modify the form item.
Well. Currently, form validation change event is the same as 'change' event.
If we ignore complicated cases (for example, using multiple), this issue can be addressed by emitting validation change event whenever the value changes. (That's basically what el-input is doing).
I hope that each time the value of the modification can trigger validation, because this is very useful in complex forms, if you need to manually trigger form validation every time, that would be very difficult in projects with complex forms, I hope Even if you really want to remove the auto-verification, at least provide a switch to let me turn on auto-calibration, because this function is really very important in actual use.
I will look into a fix soon. Most likely it will auto validate similarly to el-input.
I will look into a fix soon. Most likely it will auto validate similarly to el-input.
The 'blur' event on the select component seems not work same as the 'input' ?
Most helpful comment
I will look into a fix soon. Most likely it will auto validate similarly to el-input.