使用uniapp写一个登录页面
时间: 2023-12-23 22:03:05 浏览: 24
好的,下面是一个简单的登录页面的代码示例:
```html
<template>
<view class="container">
<form>
<input type="text" placeholder="请输入用户名" v-model="username" />
<input type="password" placeholder="请输入密码" v-model="password" />
<button type="submit" @click="login">登录</button>
</form>
</view>
</template>
<script>
export default {
data() {
return {
username: '',
password: ''
}
},
methods: {
login() {
// 在这里处理登录逻辑
console.log('用户名:', this.username)
console.log('密码:', this.password)
}
}
}
</script>
<style>
.container {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
form {
display: flex;
flex-direction: column;
align-items: center;
}
input {
margin-bottom: 20px;
padding: 10px;
border: none;
border-radius: 5px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
font-size: 16px;
}
button {
padding: 10px 20px;
border: none;
border-radius: 5px;
background-color: #007aff;
color: #fff;
font-size: 18px;
cursor: pointer;
}
</style>
```
上面的代码使用了uniapp框架开发,包含了一个简单的登录界面。其中,通过`v-model`指令将输入框中的值绑定到了`data`中的`username`和`password`属性上,通过`@click`事件绑定了登录按钮的点击事件,并在`login`方法中处理了登录逻辑。最后,使用了一些CSS样式来美化界面。