code show as below:
**validateCode:[{validator:(rule, value, callback)=>{ if (!value) { callback(new Error('you have to input code')) } else if(this.radioValue=="mobile"){ validatingCo(this.user.mobile,value).then((res)=>{ if(!res.code==20000){ return callback(new Error('the code is wrong or expired')) } else{ callback() } }) } else{ validatingCo(this.user.email,value).then((res)=>{ if(!res.code==20000){ return callback(new Error('the code is wrong or expired')) } else{ callback() } }) } }, trigger:'blur'}]
Unfortunately, it doesn't execute and there are no errors. I want to know how to deal with it.
I think the problem may be caused by this line:
It should probably be:
!res.code
will always evaluate totrue
orfalse
. So!res.code==20000
will always be false. No matter what is entered, the following error callbacks will not be executed:Here is a small demonstration showing that "bar" will always be printed