vue element ui validate Active Trigger Error Prompt Operation
- 2021-08-21 19:43:45
- OfStack
elementUI uses async-validator for form validation, but when I use the drop-down tree (el-cascader), I find that it does not trigger actively, so I can only trigger actively, as follows:
this.$refs['form'].fields[0].validateMessage = 'error message'
this.$refs['form'].fields[0].validateState = 'error'
Additional knowledge: element-ui Open Page Triggers Verification Problem
If you set resetFields () when you close the pop-up page, the verification effect will still be triggered when you open the page, which is generally caused by drop-down box and time selection. The solution is to change the verification rule rules.
endTime: [{type: 'string', required: true, message: 'Please select', trigger: 'blur'}],
type: [{type: 'number', required: true, message: 'Please select', trigger: 'blur'}],
At this point, your drop-down selection type should be correct, just like me. At this point, value of the drop-down box is number, so this is number. If your drop-down box corresponds to value, the type will change accordingly.
At the same time, element-ui has a pit, time zone problem, which leads to an 8-hour difference between the time transmitted to the background and the selected time. At this time, you need to set
value-format="yyyy-MM-dd HH:mm:ss"
In this way, it is a string to pass to the background. When checking, it needs to follow the rules of endTime