[Pit] element form validation pit: validate type error & prompt "is not a string"

Some problems encountered at work, the verification function of the element form component, stepped on the second time... and they were all small mistakes, stuck for a long time.

validate type error

Bug performance: the form item is always validated and returns an error, and the validate variable displays type error when debugging

Reason: The data of the form in data has a hierarchical relationship, but it was not considered when prop was used, mainly because the principle of prop verification rules is not familiar. The value of prop must be consistent with the hierarchical relationship of the current form data.

for example

Data: {
    
    a: 'a', b: 'b', c: {
    
    aa: 'aa', bb: 'bb'}}

Prop checks data a, then prop="a", if it is checking aa, then prop="c.aa", and the key of rules should also be changed to 'c.aa': [{}].

is not a string

This problem is even more stupid. Check the custom rules, whether the validator is written as validate for granted... Pure typos can make you spend a long time finding the problem.

Guess you like

Origin blog.csdn.net/DrLemonPie/article/details/123924881