用uniapp写一个登录页
时间: 2023-05-21 11:06:20 浏览: 156
好的,我可以为您解答该问题。
以下是用uniapp编写登录页面的简单代码:
<template>
<view class="container">
<view class="logo">
<image src="../../static/logo.png"></image>
<text class="logo-text">登录页</text>
</view>
<view class="form">
<input placeholder="请输入用户名" v-model="username"></input>
<input placeholder="请输入密码" type="password" v-model="password"></input>
<button @click="handleLogin">登录</button>
</view>
</view>
</template>
<script>
export default {
data() {
return {
username: '',
password: ''
}
},
methods: {
handleLogin() {
// 实现登录逻辑,可以根据实际需求自定义
}
}
}
</script>
以上代码是一个简单的登录页面,包含用户名、密码输入框以及登录按钮,您可以根据需要自由扩展和修改。
相关问题
用uniapp写一个登录页面
好的,以下是用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>
使用uniapp写一个登录页面
好的,下面是一个简单的登录页面的代码示例:
```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样式来美化界面。