Sfoglia il codice sorgente

feat: 登录前端校验

cuiyalong 10 mesi fa
parent
commit
730e58745b
1 ha cambiato i file con 13 aggiunte e 0 eliminazioni
  1. 13 0
      frontend/src/views/Login.vue

+ 13 - 0
frontend/src/views/Login.vue

@@ -40,6 +40,19 @@ const form = ref({})
 const loading = ref(false)
 //
 const doLogin = async () => {
+    if (!form.value.username) {
+        return ElMessage({
+            message: '用户名不能为空!',
+            type: 'error',
+        })
+    }
+    if (!form.value.password) {
+        return ElMessage({
+            message: '密码不能为空!',
+            type: 'error',
+        })
+    }
+
     loading.value = true
     //TODO 这里需要调用后台方法实现登录
     try {