浅写前后端分离搭建一个服务器实现登录功能

前端网页--客户端

结构层--html代码

 <div class="login">

        <form action="">
            <div class="input">
                <div class="label">账号:</div>
                <div>
                    <input type="text" name="username" id="username" placeholder="请输入账号">
                    <div class="tip H"></div>
                </div>
            </div>
            <div class="input">
                <div class="label">密码:</div>
                <div>
                    <input type="password" name="passwd" id="passwd" placeholder="请输入密码">
                    <div class="tip H"></div>
                </div>
            </div>
            <div class="btn"> 登录 </div>
        </form>
    </div>

    <script src="./js/login.js" type="module"></script>

表现层--sass生成css代码

@import './module/variable';    /** 为后面的模块提供变量*/
@import './module/common';      /** 公用基础样式*/
@import './module/login';       /** 登录页面的样式*/
@import './module/nav';         /** 导航样式*/

公共基础样式

*{
    margin: 0;
    padding: 0;
}

li{
    list-style: none;
}
body{
    font-family: Roboto,-apple-system,Nimbus Roman No9 L,PingFang SC,Hiragino Sans GB,Noto Sans SC,Microsoft Yahei,WenQuanYi Micro Hei,ST Heiti,EuclidCircularA,sans-serif;
    -webkit-font-smoothing: antialiased;
}
a {
    color: #202020;
}
a:active, a:hover, a:link, a:visited {
    text-decoration: none;
}


input{
    width: 200px;
    height: 36px;
    line-height: 36px;
    padding: 0 8px;
    border: 1px solid #ededed;
    outline: none;
}

.btn{
    width: 200px;
    margin: auto;
    height: 42px;
    line-height: 42px;
    text-align: center;
    border-radius: 8px;
    -webkit-border-radius: 8px;
    -moz-border-radius: 8px;
    -ms-border-radius: 8px;
    -o-border-radius: 8px;
    background-color: rgb(12, 238, 99);
    color: #fff;
    cursor: pointer;
    font-size: 20px;
    font-weight: 500;
    margin-top: 20px;

}
.H{
    color:red;
    background-color: #0f0;
}

登录页面样式

.login {
    width: 100%;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    >form{
        width: 300px;
        height: 200px;

        >.input{
            display: flex;
            margin-bottom: 12px;
            align-items: center;
        }
    }
    .label{
        font-size: 16px;
        font-weight: 500;
    }
}

行为层--js代码

封装函数--获取选择器

class jQuery {
    /** 构造函数:在实例化的时候会自动执行 */
    constructor(selector) {
        if (typeof selector != 'string') {
            console.error(new Error('selector is  invaild...'));
            return new Error('selector is  invaild...');
        }
        this.node = document.querySelector(selector);
    }

    click(eventFn, capture = false) {
        if(typeof eventFn != 'function'){
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值