uniapp注册页面代码
时间: 2023-08-25 18:07:22 浏览: 70
当然,这是一个简单的 Uniapp 注册页面的代码示例:
```html
<template>
<div class="register">
<h2>用户注册</h2>
<form>
<div class="form-group">
<label for="username">用户名</label>
<input type="text" id="username" v-model="username" required>
</div>
<div class="form-group">
<label for="password">密码</label>
<input type="password" id="password" v-model="password" required>
</div>
<div class="form-group">
<label for="confirmPassword">确认密码</label>
<input type="password" id="confirmPassword" v-model="confirmPassword" required>
</div>
<button type="submit" @click.prevent="register">注册</button>
</form>
</div>
</template>
<script>
export default {
data() {
return {
username: '',
password: '',
confirmPassword: ''
}
},
methods: {
register() {
// 在这里处理注册逻辑
if (this.password !== this.confirmPassword) {
alert('密码不一致');
return;
}
// 发送注册请求到后端
// ...
alert('注册成功!');
}
}
}
</script>
<style scoped>
.register {
margin: 20px auto;
max-width: 400px;
}
.form-group {
margin-bottom: 10px;
}
label {
display: block;
margin-bottom: 5px;
}
input[type="text"],
input[type="password"] {
width: 100%;
padding: 5px;
}
</style>
```
这是一个简单的注册页面,包含用户名、密码和确认密码的输入框,以及一个注册按钮。点击注册按钮时,会进行一些基本的表单验证,然后发送注册请求到后端。请根据你的需求进行更改和调整。