登录页面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>
相关推荐
Larcher3 小时前
React Router 不只是页面跳转:从 SPA 路由到权限守卫的完整实践
javascript·后端
Larcher3 小时前
大模型为什么每次回答都不一样?一文搞懂 Temperature、Top K 与 Top P
javascript·后端
用户938515635075 小时前
从零在浏览器里跑 DeepSeek-R1:WebGPU + Transformer.js 全链路实战
前端·设计模式·typescript
CodeSheep6 小时前
稚晖君公司人事大变动,来了!
前端·后端·程序员
鱼樱前端6 小时前
用 AI 做内容变收入
前端·人工智能·ai编程
eric-sjq6 小时前
10 分钟实战:用 0.6B 本地模型生成中文网页(WanlyFrontend + 编译器全流程)
javascript·机器学习·自然语言处理·html
浮生望6 小时前
React + TypeScript 组件设计进阶:从类型约束到无状态组件的三次进化
前端
To_OC7 小时前
LC 438 找到所有字母异位词:暴力超时后,我靠滑动窗口一招搞定
javascript·算法·leetcode
90后的晨仔7 小时前
Mac 开发 uni-app 终极方案:让安卓模拟器彻底脱离 Android Studio 独立运行
前端·vue.js
90后的晨仔7 小时前
别再搞混了!uni-app 中 node_modules 和 uni_modules 到底是什么关系?
前端