需要一个vue登录页面
以下是一个简单的Vue登录页面示例:
<template>
<div class="login">
<h1>登录</h1>
<form @submit.prevent="login">
<label>
用户名:
<input type="text" v-model="username" required>
</label>
<label>
密码:
<input type="password" v-model="password" required>
</label>
<button type="submit">登录</button>
</form>
</div>
</template>
<script>
export default {
data() {
return {
username: '',
password: ''
}
},
methods: {
login() {
// 这里可以添加登录逻辑
console.log('用户名:', this.username)
console.log('密码:', this.password)
}
}
}
</script>
<style>
.login {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
}
h1 {
font-size: 2rem;
margin-bottom: 2rem;
}
form {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
label {
display: flex;
flex-direction: column;
margin-bottom: 1rem;
}
input {
padding: 0.5rem;
font-size: 1rem;
border-radius: 0.25rem;
border: 1px solid #ccc;
}
button {
margin-top: 1rem;
padding: 0.5rem 1rem;
font-size: 1rem;
border-radius: 0.25rem;
border: none;
background-color: #007bff;
color: #fff;
cursor: pointer;
}
</style>
这个登录页面包含一个表单,其中有一个用户名输入框和一个密码输入框,并有一个登录按钮。当用户点击登录按钮时,表单将被提交,并使用login方法处理提交事件。在login方法中,您可以添加登录逻辑,例如向服务器发送登录请求并验证用户凭据。在这个例子中,我们只是在控制台上打印出用户名和密码。
原文地址: https://www.cveoy.top/t/topic/D92 著作权归作者所有。请勿转载和采集!