登录页面form表单

登录页面form表单

html 复制代码
<template>
  <div class="login-container">
    <div class="login-box">
      <el-form ref="ruleFormRef" :model="form" :rules="rules">
        <el-form-item prop="username">
          <el-input v-model="form.username" :clearable="true" maxlength="11" placeholder="手机号/邮箱"></el-input>

        </el-form-item>

        <el-form-item prop="password">
          <el-input v-model="form.password" :clearable="true" min="6" type="password" style="margin-top: 20px"
                    placeholder="密码"></el-input>
        </el-form-item>

        <el-form-item>
          <el-button @click="loginFun(ruleFormRef)" type="primary" class="btn">登录</el-button>
        </el-form-item>

      </el-form>

    </div>
  </div>
</template>

<script setup lang="js">
import {reactive, ref} from "vue";

const form = ref({
  username: "",
  password: "",
})

const ruleFormRef = ref()
const rules = reactive({
  username: [
    {required: true, message: '请输入用户名', trigger: 'blur'},
    {min: 3, max: 11, message: '非法输入!', trigger: 'blur'},
  ],
  password: [
    {required: true, message: '请输入密码', trigger: 'blur'},
    {max: 16, message: '非法输入', trigger: 'blur'},
  ]
})

const loginFun = async (formEl) => {

  if (!formEl) return
  
  await formEl.validate((valid, fields) => {
    if (valid) {
      console.log('submit!')
    } else {
      console.log('error submit!', fields)
    }
  })

}
</script>

<style scoped lang="scss">
.login-container {
  width: 100%;
  height: 100%;
  background-image: url("@/assets/image/index/clearBackground.png");
  text-align: center;
  background-size: 100% 100%;
  user-select: none;
  display: flex;
  justify-content: center;
  align-items: center;

  .login-box {
    width: 400px;
    height: 200px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 10px;
    /* box-shadow: 水平阴影 垂直阴影 模糊距离 阴影尺寸 阴影颜色 内外阴影;*/
    box-shadow: 2px 2px 5px 2px rgba(168, 168, 168, 0.4);
    border: 1px solid silver;
    padding: 30px 20px;

    .btn {
      width: 100%;
      margin-top: 30px;
      height: 38px;
    }

  }


}
</style>
相关推荐
不简说3 小时前
JS 代码技巧 vol.1 — 10 个让代码少写 30% 的小套路
前端·javascript·面试
@@@@@@@@543 小时前
JavaScript 的缺点与 TypeScript 的弥补
开发语言·javascript·typescript
Hilaku3 小时前
为什么业务型前端容易遭遇中年危机?
前端·javascript·程序员
এ慕ོ冬℘゜4 小时前
深度解析 JavaScript:赋予 Web 灵魂的“全栈语言”
开发语言·前端·javascript
iCOD3R4 小时前
Skill - 3秒生成精美GitHub主页
前端·程序员·ai编程
爱勇宝4 小时前
《道德经》第5章:生产环境不相信眼泪
前端·后端·架构
掘金者阿豪4 小时前
LEFT JOIN 凭空消失的背后,是优化器偷偷帮你做了决定
前端·后端
HackTwoHub4 小时前
AntiDebug Mcp、AI逆向绕过前端,Hook 加密接口,抓取 Vue 路由漏洞,接入 MCP 让 AI 自动化挖掘前端漏洞
前端·vue.js·人工智能·安全·web安全·网络安全·系统安全
Mr_凌宇4 小时前
AI 应用工程进阶扩展学习笔记 二
前端·面试
Hyyy4 小时前
Git Worktree 完全讲解
前端·后端·面试