用uniapp写一个登录页面
时间: 2023-05-22 16:05:22 浏览: 68
好的,以下是用uniapp写一个登录页面的示例代码:
<template>
<view class="container">
<view class="header">欢迎登录</view>
<form class="form" @submit="submitForm">
<label class="label">
<text class="text">用户名:</text>
<input class="input" v-model="username" type="text" name="username" />
</label>
<label class="label">
<text class="text">密码:</text>
<input class="input" v-model="password" type="password" name="password" />
</label>
<button class="button" type="submit">登录</button>
</form>
</view>
</template>
<script>
export default {
data() {
return {
username: '',
password: '',
};
},
methods: {
submitForm(event) {
event.preventDefault();
// 处理登录逻辑
},
},
};
</script>
<style>
.container {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
background-color: #f5f5f5;
}
.header {
font-size: 24px;
font-weight: bold;
margin: 16px;
}
.form {
display: flex;
flex-direction: column;
gap: 16px;
padding: 16px;
border-radius: 8px;
background-color: #fff;
}
.label {
display: flex;
flex-direction: column;
gap: 8px;
}
.text {
font-size: 18px;
font-weight: bold;
}
.input {
padding: 8px;
border-radius: 4px;
border: 1px solid #ccc;
}
.button {
padding: 8px 16px;
border-radius: 4px;
background-color: #007aff;
color: #fff;
font-size: 18px;
font-weight: bold;
cursor: pointer;
}
</style>