浏览代码

feat: 登录前端校验

cuiyalong 10 月之前
父节点
当前提交
730e58745b
共有 1 个文件被更改,包括 13 次插入0 次删除
  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 loading = ref(false)
 //
 //
 const doLogin = async () => {
 const doLogin = async () => {
+    if (!form.value.username) {
+        return ElMessage({
+            message: '用户名不能为空!',
+            type: 'error',
+        })
+    }
+    if (!form.value.password) {
+        return ElMessage({
+            message: '密码不能为空!',
+            type: 'error',
+        })
+    }
+
     loading.value = true
     loading.value = true
     //TODO 这里需要调用后台方法实现登录
     //TODO 这里需要调用后台方法实现登录
     try {
     try {