VUE登录注册页面,完整vue,直接复制

效果图:

Login.vue

<template>
    <div class="container">
            <div class="login-wrapper">
                <div class="header">Login</div>
                <div class="form-wrapper">
                    <input type="text" name="username" placeholder="username" class="input-item">
                    <input type="password" name="password" placeholder="password" class="input-item">
                    <div class="btn">Login</div>
                </div>
            </div>
        </div>
</template>

<script>
    export default {
        name:"Login"
    }
</script>

<style scoped>

html {
    height: 100%;
}
body {
    height: 100%;
}
.container {
    /* margin-top: 5%; */
    height: 980px;
    width: 100%;
    background-image: linear-gradient(to right, #fbc2eb, #a6c1ee);
}
.login-wrapper {
    background-color: #fff;
    width: 358px;
    height: 588px;
    border-radius: 15px;
    padding: 0 50px;
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
}
.header {
    font-size: 38px;
    font-weight: bold;
    text-align: center;
    line-height: 200px;
}
.input-item {
    display: block;
    width: 100%;
    margin-bottom: 20px;
    border: 0;
    padding: 10px;
    border-bottom: 1px solid rgb(128, 125, 125);
    font-size: 15px;
    outline: none;
}
.input-item:placeholder {
    text-transform: uppercase;
}
.btn {
    text-align: center;
    padding: 10px;
    margin: 0 auto;
    width: 100%;
    margin-top: 40px;
    background-image: linear-gradient(to right, #a6c1ee, #fbc2eb);
    color: #fff;
}
.msg {
    text-align: center;
    line-height: 88px;
}
a {
    text-decoration-line: none;
    color: #abc1ee;
}

</style>

Register.vue

<template>
    <div class="container">
            <div class="login-wrapper">
                <div class="header">Register</div>
                <div class="form-wrapper">
                    <input type="text" name="username" placeholder="账户" class="input-item">
                    <input type="password" name="password" placeholder="密码" class="input-item">
                    <input type="password" name="repassword" placeholder="再次确认密码" class="input-item">
                    <div class="btn">Register</div>
                </div>
            </div>
        </div>
</template>
    
<script>
    export default {
        name:"Reg"
    }
</script>

<style scoped>
html {
    height: 100%;
}
body {
    height: 100%;
}
.container {
    /* margin-top: 5%; */
    height: 980px;
    width: 100%;
    background-image: linear-gradient(to right, #fbc2eb, #a6c1ee);
}
.login-wrapper {
    background-color: #fff;
    width: 358px;
    height: 588px;
    border-radius: 15px;
    padding: 0 50px;
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
}
.header {
    font-size: 38px;
    font-weight: bold;
    text-align: center;
    line-height: 200px;
}
.input-item {
    display: block;
    width: 100%;
    margin-bottom: 20px;
    border: 0;
    padding: 10px;
    border-bottom: 1px solid rgb(128, 125, 125);
    font-size: 15px;
    outline: none;
}
.input-item:placeholder {
    text-transform: uppercase;
}
.btn {
    text-align: center;
    padding: 10px;
    width: 100%;
    margin-top: 40px;
    background-image: linear-gradient(to right, #a6c1ee, #fbc2eb);
    color: #fff;
    margin: 0 auto;
}
.msg {
    text-align: center;
    line-height: 88px;
}
a {
    text-decoration-line: none;
    color: #abc1ee;
}

</style>

由于显示的分辨率和比例不同,最终展示可能出现位置不对等问题,主要调节<style>中.container的height属性和.login-wrapper的transform:属性

App.vue也奉上:

<template>
  <div id="app">
      <div class="title">
          <div class="btn" @click="msg='Login'">登录</div>
          <div class="btn" @click="msg='Reg'">注册</div>
      </div>
      <component :is="msg"></component>
  </div>
</template>

<script>
//这里的from路径根据自己的布局更改路径
import Login from './components/login.vue'
import Reg from './components/register.vue'
export default {
  name: 'App',
  data(){
      return{
          msg:"Login"
      }
  },
  components: {
    Login,
    Reg
  }
}
</script>

<style>
.title{
    text-align: center;
    background-image: linear-gradient(to right, #fbc2eb, #a6c1ee);
}
.btn {   
    background-color: rgb(210,193,326);
    border-radius:28px;
    border:1px solid #ffffff;
    display:inline-block;
    cursor:pointer;
    color:#ffffff;
    font-family:Arial;
    font-size:17px;
    padding:16px 31px;
    text-decoration:none;
    text-shadow:0px 1px 0px #2f6627; 
    margin: 10px 20px;  
}
.btn:hover {
    background-color:rgb(180,193,237);
}
.btn:active {
    position:relative;
    top:1px;
}
</style>

  • 47
    点赞
  • 490
    收藏
    觉得还不错? 一键收藏
  • 9
    评论
以下是一个简单的Vue登录注册页面代码示例: ```html <template> <div> <h2>登录</h2> <form> <div> <label for="username">用户名:</label> <input type="text" id="username" v-model="username" /> </div> <div> <label for="password">密码:</label> <input type="password" id="password" v-model="password" /> </div> <button type="button" @click="handleLogin">登录</button> </form> <hr /> <h2>注册</h2> <form> <div> <label for="new-username">用户名:</label> <input type="text" id="new-username" v-model="newUsername" /> </div> <div> <label for="new-password">密码:</label> <input type="password" id="new-password" v-model="newPassword" /> </div> <div> <label for="confirm-password">确认密码:</label> <input type="password" id="confirm-password" v-model="confirmPassword" /> </div> <button type="button" @click="handleRegister">注册</button> </form> </div> </template> <script> export default { data() { return { username: '', password: '', newUsername: '', newPassword: '', confirmPassword: '', } }, methods: { handleLogin() { // 处理登录逻辑 console.log('登录:', this.username, this.password) }, handleRegister() { // 处理注册逻辑 console.log('注册:', this.newUsername, this.newPassword, this.confirmPassword) }, }, } </script> <style scoped> /* 样式 */ </style> ``` 这个示例包含了一个登录表单和一个注册表单,每个表单都由一些输入字段和一个提交按钮组成。每个输入字段都使用 `v-model` 指令绑定到组件的数据属性上。 登录和注册按钮都有一个 `@click` 监听器,当用户点击按钮时,将会调用相应的处理方法来执行登录或注册逻辑。在这个示例中,这些处理方法只是简单地打印出表单字段中的值。在实际应用中,这些方法将会发出网络请求来与后端服务通信。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值