7月10号总结 (1)

今天开始写web项目,画了一下登录界面,借鉴了一下网上的资源。

html 复制代码
<!DOCTYPE html>
<html lang="zh.CN">
  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>登录系统</title>
    <style>
      /* Flex布局实现垂直水平居中 */
      body {
        margin: 0;
        height: 100vh;
        display: flex;
        justify-content: center;
        align-items: center;
        background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
        font-family: 'Arial', sans-serif;
      }

      .login-container {
        width: 350px;
        padding: 40px;
        background: white;
        border-radius: 10px;
        box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
        animation: fadeIn 0.5s ease;
      }

      @keyframes fadeIn {
        from { opacity: 0; transform: translateY(-20px); }
        to { opacity: 1; transform: translateY(0); }
      }

      h2 {
        text-align: center;
        margin-bottom: 30px;
      }

      .input-group{
        margin-bottom: 20px;
        position: relative;
      }

      input {
        width: 100%;
        padding: 12px 15px;
        border: 1px solid #ddd;
        border-radius: 5px;
        font-size: 16px;
        transition: border 0.3s;
      }

      input:focus {
        border-color: #4285f4;
        outline: none;
        box-shadow: 0 0 0 2px rgba(66, 133, 244, 0.2);
      }

      label {
        position: absolute;
        left: 15px;
        top: 12px;
        color: #999;
        transition: all 0.3s;
        pointer-events: none;
      }

      input:focus + label,
      input:not(:placeholder-shown) + label {
        top: -10px;
        left: 10px;
        font-size: 12px;
        background: white;
        padding: 0 5px;
        color: #4285f4;
      }

      button {
        width: 100%;
        padding: 12px;
        background: #4285f4;
        color: white;
        border: none;
        border-radius: 5px;
        font-size: 16px;
        cursor: pointer;
        transition: background 0.3s;
      }
      button:hover {
        background: #3367d6;
      }

      .error-message {
        color: #d32f2f;
        font-size: 14px;
        margin-top: 5px;
        height: 20px;
      }
    </style>

  </head>
  <body>
    <!--    登录的容器   -->
    <div class="login-container">
      <h2>欢迎登录</h2>
      <form action="" id="loginForm">
        <div class="input-group">
          <input type="text" id="username" autocomplete="off" placeholder=" ">
          <label for="username"> 用户名</label>
          <div class="error-message" id="username-error"></div>
        </div>
        <div class="input-group">
          <input type="password" id="password" placeholder=" ">
          <label for="password"> 密码</label>
          <div class="error-message" id="password-error"></div>
        </div>
        <button typr="submit">登 录</button>
      </form>
      <script>
        let lf = document.getElementById("loginForm");
        lf.addEventListener("submit", async(e)=>{
          //这个的意思就是在提交之前我检查一下你的格式是否正确
          //相当于是正则表达式
          e.preventDefault();// 防止表单提交

          const username=document.getElementById("username").value.trim();
          const password=document.getElementById("password").value;

          if (!username){
            document.getElementById("username-error").textContent="请输入用户名";
              return;
                    }
                    if (!password){
                      document.getElementById("password-error").textContent="请输入密码";
                    return;
                    }

                    // 验证是否包含特殊字符
                    const regex = /[!@#$%^&*(),.?":{}|<>]/; // 定义特殊字符的正则表达式
                      if(!regex.test(username)){
                        document.getElementById("password-error").textContent='用户名至少包含一个特殊字符';
                      }

                      })

                    </script>
                  </div>
                </body>
              </html>

还写了类似于一个正则表达式的东西,密码必须带有特殊字符,否则提示错误

jsx 复制代码
// 验证是否包含特殊字符
const regex = /[!@#$%^&*(),.?":{}|<>]/; // 定义特殊字符的正则表达式
if(!regex.test(username)){
  document.getElementById("password-error").textContent='用户名至少包含一个特殊字符';
}

画了一个er图

用户有哪些属性

用户:ID、用户名、密码、性别、生日(吧龄)、头像、年龄、账号状态、个人简介、粉丝、关注、IP地址、最后IP地址、创建时间、评论

有些没有属性没有写到,到时候慢慢添加

还学了些建表的操作语句

接下来边学习双token边写

相关推荐
子兮曰1 小时前
async/await高级模式:async迭代器、错误边界与并发控制
前端·javascript·github
恋猫de小郭1 小时前
2026 Flutter VS React Native ,同时在 AI 时代 VS Native 开发,你没见过的版本
android·前端·flutter
GIS之路3 小时前
ArcGIS Pro 中的 Notebooks 入门
前端
IT_陈寒5 小时前
React状态管理终极对决:Redux vs Context API谁更胜一筹?
前端·人工智能·后端
Kagol6 小时前
TinyVue 支持 Skills 啦!现在你可以让 AI 使用 TinyVue 组件搭建项目
前端·agent·ai编程
柳杉6 小时前
从零打造 AI 全球趋势监测大屏
前端·javascript·aigc
simple_lau6 小时前
Cursor配置MasterGo MCP:一键读取设计稿生成高还原度前端代码
前端·javascript·vue.js
睡不着先生6 小时前
如何设计一个真正可扩展的表单生成器?
前端·javascript·vue.js
天蓝色的鱼鱼6 小时前
模块化与组件化:90%的前端开发者都没搞懂的本质区别
前端·架构·代码规范
明君879976 小时前
Flutter 如何给图片添加多行文字水印
前端·flutter