Parcourir la source

fix: 修复useValidator报错

kailong321200875 il y a 1 an
Parent
commit
4912f6c058
1 fichiers modifiés avec 1 ajouts et 1 suppressions
  1. 1 1
      src/hooks/web/useValidator.ts

+ 1 - 1
src/hooks/web/useValidator.ts

@@ -30,7 +30,7 @@ export const useValidator = () => {
   const notSpace = (message?: string): FormItemRule => {
     return {
       validator: (_, val, callback) => {
-        if (val.indexOf(' ') !== -1) {
+        if (val?.indexOf(' ') !== -1) {
           callback(new Error(message || t('common.notSpace')))
         } else {
           callback()