登录页面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>
相关推荐
亿元程序员9 分钟前
微信小游戏备案很久?这样操作可以直接发布!
前端
福狼17 分钟前
The Expanse:让风沙成为世界的一部分
前端·three.js
桃李无言下自成蹊21 分钟前
为什么越清晰的二维码越扫不出来:jsQR 四轮解码与 8 个真实坑
javascript
程序员鱼皮22 分钟前
这 3 年 AI Agent 到底进化了啥?万字大白话,一次讲透!
前端·后端·aigc
用户9003050936226 分钟前
Claude Code平替评测:换掉之前先理清楚这些选型条件
前端
bai27328 分钟前
同一个 JSON,Node 读出了三种坏法:Windows 上四种写法的编码实测
前端
ZANE28 分钟前
纯前端实现的 .gitignore 生成器技术实现
前端
小y的笔记37 分钟前
Vue 3 异步搜索实战:watch、请求取消与竞态控制
前端·javascript
sanxing三省1 小时前
DeepSeek Harness 到底是什么?标题里最重的词其实不是「DeepSeek」
前端·人工智能·deepseek
jianqiang.xue1 小时前
把Agent塞进MCU:工具次数和上下文长度怎么卡
java·前端·网络·单片机·esp32·ai编程