写一个vue的登录页面
时间: 2023-10-25 19:05:36 浏览: 23
好的,我可以给您提供一个简单的Vue登录页面的代码,如下所示:
```
<template>
<div class="login">
<h2>Login</h2>
<form @submit.prevent="submitForm">
<div class="form-group">
<label for="username">Username</label>
<input type="text" id="username" v-model="form.username" required>
</div>
<div class="form-group">
<label for="password">Password</label>
<input type="password" id="password" v-model="form.password" required>
</div>
<button type="submit">Login</button>
</form>
</div>
</template>
<script>
export default {
data: function() {
return {
form: {
username: '',
password: ''
}
}
},
methods: {
submitForm: function() {
// Here you can write your backend code to handle login authentication
console.log(this.form);
}
}
}
</script>
<style>
.login {
margin: 0 auto;
width: 300px;
text-align: center;
}
h2 {
color: #0688fa;
}
.form-group {
width: 100%;
margin-bottom: 15px;
text-align: left;
}
label {
display: inline-block;
margin-bottom: 5px;
color: #0688fa;
}
input {
width: 100%;
height: 34px;
padding: 6px 12px;
font-size: 14px;
line-height: 1.42857143;
color: #555;
background-color: #fff;
background-image: none;
border: 1px solid #ccc;
border-radius: 4px;
}
button {
display: block;
margin: 0 auto;
padding: 6px 12px;
font-size: 14px;
font-weight: normal;
line-height: 1.42857143;
text-align: center;
white-space: nowrap;
vertical-align: middle;
cursor: pointer;
background-image: none;
border: 1px solid transparent;
border-radius: 4px;
color: #fff;
background-color: #0688fa;
}
</style>
```
您可以将这段代码复制到您的Vue项目中,然后根据您的需要对其进行修改。希望这能对您有所帮助!