登录页面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>
相关推荐
threelab19 分钟前
Three.js UV 图像变换效果 | 三维可视化 / AI 提示词
javascript·人工智能·uv
之歆38 分钟前
DAY08_CSS浮动与行内块布局实战指南(下)
前端·css
yqcoder1 小时前
CSS Position 全解析:5 种定位模式详解
前端·css
Rhi6371 小时前
从零搭建项目:React 19 + Vite 8 + Tailwind CSS v4 实战配置
前端
竹林8182 小时前
用Viem替代ethers.js:从一次签名失败到完整迁移的实战记录
前端·javascript
之歆2 小时前
DAY08_CSS浮动与行内块布局实战指南(上)
前端·css
light blue bird2 小时前
主子端台二分法任务汇总组件
前端·数据库·.net·桌面端winform
不可能的是3 小时前
Claude Code 子 Agent 机制全解:怎么跑起来、怎么被管理、怎么互不干扰
javascript
jeffwang3 小时前
我做了个让 AI 看屏幕跑测试的工具,因为 Playwright 测不了我的 Flutter Web
前端
HSunR3 小时前
dify 搭建ai作业批改流
开发语言·前端·javascript