登陆页面小demo

.vue文件部分代码:

<template>
  <div id="Login">
      <el-row :gutter="20">
        <el-col :span="8" :offset="8">
            <div class="box"></div>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="8" :offset="8">
          <el-card shadow="always">
              <h1 style="text-align:center">欢迎登陆</h1>
              <el-divider></el-divider>            
              <el-form :model="ruleForm"  ref="ruleForm" label-width="100px" class="demo-ruleForm">
                <el-form-item
                label="账号"
                prop="acount"
                 :rules="[
                    { required: true, message: '账户不能为空'},
                ]"
                >
                <el-input type="text" placeholder="请输入账户" v-model="ruleForm.acount" autocomplete="off"></el-input>
            </el-form-item>
                <el-form-item label="密码" prop="pass"   
                :rules="[
                    { required: true, message: '密码不能为空'},
                ]">
                    <el-input type="password" placeholder="请输入密码" v-model="ruleForm.pass" show-password></el-input>
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" @click="submitForm('ruleForm')">提交</el-button>
                    <el-button @click="resetForm('ruleForm')">重置</el-button>
                </el-form-item>
            </el-form>
          </el-card>
        </el-col>
      </el-row>
      
  </div>
</template>

<script>
export default {
    data() {
         var checkacount = (rule, value, callback) => {
     if (value === '') {
          callback(new Error('请输入账号'));
        } else {
          if (this.ruleForm.acount !== '') {
            this.$refs.ruleForm.validateField('checkacount');
          }
          callback();
        }
      };
      var validatePass = (rule, value, callback) => {
        if (value === '') {
          callback(new Error('请输入密码'));
        } else {
          if (this.ruleForm.checkPass !== '') {
            this.$refs.ruleForm.validateField('pass');
          }
          callback();
        }
      };
      return {
        ruleForm: {
          pass: '',
          acount: ''
        },
        rules: {
            acount:[
             { validator: checkacount, trigger: 'blur' }
            ],
          pass: [
            { validator: validatePass, trigger: 'blur' }
          ],
        }
      };
    },
    methods: {
      submitForm(formName) {
        this.$refs[formName].validate((valid) => {
          if (valid) {
            alert('submit!');
          } else {
            console.log('error submit!!');
            return false;
          }
        });
      },
      resetForm(formName) {
        this.$refs[formName].resetFields();
      }
    }
}
</script>

<style>
.el-card {
    justify-content: center;
    height:350px;
    width:400px;
    border-radius: 15px;
}
.box{
    height:64px;
}
</style>

main.js文件部分代码:

import Vue from 'vue'
import ElementUI from 'element-ui'
import App from'./components/App_login.vue'
Vue.use(ElementUI)
Vue.config.productionTip = false
new Vue({
    el:'#app',
    render: h=>h(App)
})

页面效果:

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
好的,我可以给您提供一个简单的登录页面的 HTML 和 CSS 代码,并且可以适配不同的屏幕大小。以下是代码示例: HTML代码: ``` <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>登录页面</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="style.css"> </head> <body> <div class="container"> <h1>欢迎登录</h1> <form> <label for="username"><b>用户名</b></label> <input type="text" placeholder="请输入用户名" name="username" required> <label for="password"><b>密码</b></label> <input type="password" placeholder="请输入密码" name="password" required> <button type="submit">登录</button> <label> <input type="checkbox" checked="checked" name="remember">记住我 </label> </form> </div> </body> </html> ``` CSS代码: ``` * { box-sizing: border-box; } body { margin: 0; font-family: Arial, Helvetica, sans-serif; background-color: #f1f1f1; } .container { padding: 16px; background-color: #fff; } h1 { text-align: center; color: #333; } input[type=text], input[type=password] { width: 100%; padding: 12px 20px; margin: 8px 0; display: inline-block; border: 1px solid #ccc; border-radius: 4px; box-sizing: border-box; } button[type=submit] { background-color: #4CAF50; color: white; padding: 14px 20px; margin: 8px 0; border: none; border-radius: 4px; cursor: pointer; width: 100%; } button[type=submit]:hover { background-color: #45a049; } label { display: block; color: #666; } input[type=checkbox] { margin-top: 16px; } @media screen and (min-width: 768px) { /* PC端样式 */ .container { width: 50%; margin: 50px auto; } } @media screen and (max-width: 767px) { /* 移动端样式 */ .container { width: 90%; margin: 50px auto; } } ``` 该页面使用了一个容器来包含登录表单,使用了一些常见的样式来美化表单元素。在 CSS 代码中,我们使用了媒体查询来适配不同大小的屏幕。在屏幕宽度大于等于 768px 时,应用 PC 端样式;在屏幕宽度小于 768px 时,应用移动端样式。 希望这个登录页面的示例能够帮助到您!

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值