2022-07-03 vue项目-通用后台管理系统(二) Login页面的样式和校验,使用element-ui表单方法实现表单的提交和重置

一.登录页面Login.vue的样式

1.实现登录页面天蓝色背景色和中间白色登录框
<template>
  <div  class="login">
     <div class="loginBox"></div>
  </div>
</template>
<style scoped>
.login {
   
    background-color: darkcyan;
    height: 100vh;
}
.loginBox {
   
    width: 450px;
    height: 350px;
    background-color: #ffffff;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%,-50%);
     border-radius: 5px;
}
</style>

在这里插入图片描述

2.实现登录框中logo引入并放置在登录框左上角
<template>
  <div  class="login">
     <div class="loginBox">
      <div class="avtor">
        <img src = 'https://s3.bmp.ovh/imgs/2023/01/27/d44acfed1a1f8b1b.jpg' />
      </div> 
     </div>
  </div>
</template>
<style scoped>
.login {
   
    background-color: darkcyan;
    height: 100vh;
}
.loginBox {
   
    width: 450px;
    height: 350px;
    background-color: #ffffff;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%,-50%);
     border-radius: 5px;
}
.avtor{
   
  width: 60px;
  height: 60px;
  background: #ffffff;
  border-radius: 50%;
  border:1px solid #eee;
  padding:5px;
  box-shadow:0 0 10px #dddddd;
  position: absolute;
  transform: translate(-15%,-15%);
}
.avtor img{
   
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: #eee;
}
</style>

在这里插入图片描述

3.使用Element-UI表单功能实现用户密码的输入框样式

template:

<el-form class="loginForm" label-width="60px">
	  <el-form-item label="用户名">
	     	 <el-input prefix-icon="iconfont icon-username" placeholder="请输入用户名"></el-input>
	  </el-form-item>
	  <el-form-item label="密码">
	  	    <el-input prefix-icon="iconfont icon-password" placeholder="请输入密码"></el-input>
	  </el-form-item>
	  <el-form-item class=
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
好的,以下是一个简单的登录页面的代码示例: ```html <template> <div class="login-container"> <el-form ref="loginForm" :model="loginForm" :rules="loginRules" class="login-form"> <el-form-item prop="username"> <el-input v-model="loginForm.username" placeholder="请输入用户名"></el-input> </el-form-item> <el-form-item prop="password"> <el-input v-model="loginForm.password" type="password" placeholder="请输入密码"></el-input> </el-form-item> <el-form-item> <el-button type="primary" @click="login">登录</el-button> </el-form-item> </el-form> </div> </template> <script> import { reactive } from 'vue'; import { ElForm, ElFormItem, ElInput, ElButton } from 'element-plus'; export default { name: 'LoginPage', components: { ElForm, ElFormItem, ElInput, ElButton, }, setup() { const loginForm = reactive({ username: '', password: '', }); const loginRules = { username: [{ required: true, message: '请输入用户名', trigger: 'blur' }], password: [{ required: true, message: '请输入密码', trigger: 'blur' }], }; const login = () => { // TODO: 登录逻辑 console.log('登录'); }; return { loginForm, loginRules, login, }; }, }; </script> <style scoped> .login-container { display: flex; justify-content: center; align-items: center; height: 100vh; } .login-form { width: 400px; } </style> ``` 此示例使用Vue3 和 Element-UI,通过 reactive API 实现数据的响应式,使用 ElForm、ElFormItem、ElInput、ElButton 组件构建登录表单。需要注意的是,这里的代码仅为一个简单示例,实际开发中还需要处理表单校验、登录逻辑等方面。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

前端OnTheRun

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值