请教一个小问题
ytianzaishui opened this issue · comments
Alexander Kache commented
export async function validate( ref: Ref | any, isGetError = false ): Promise<boolean | { valid: boolean; object: any }> { const validateFn = unref(ref).validate console.log(validateFn) return new Promise((resolve) => validateFn((valid: boolean, object: any) => isGetError ? resolve({ valid, object }) : resolve(valid) ) ) }
你封装了验证是基于同步的,如果我需要在验证的过程中调用store向后台发起请求,获取到后台的数据password进行验证怎么操作呢??
李祥 commented
@Chen-WeiZhen
这个validate方法是基于element-plus的form的,他做的也只是前台校验吧,就是校验规则可以写在前台的
像校验密码这种规则肯定不能放到前台的就不需要用这个了吧,我个人感觉后台校验失败,前台直接给出提示就可以了