使用element-plus实现登录/注册页面
登录/app开发定制公司注册页面组件
vue3 app开发定制公司的登录和注册页面
app开发定制公司目前只有框架和函数框架, 根据具体需要填充,
已有功能:
1.没有勾选同意使用手册, 登录和注册按钮是处于隐藏状态的
2.密码与确认密码不一致确认
3.其余功能处于待填充状态
<template> <div class="layout"> <el-tabs type="border-card"> <el-tab-pane label="登录"> <el-form label-position="right" label-width="60px" style="max-width: 460px" class="loginForm" > <el-form-item label="邮箱:"> <el-input v-model="Email" /> </el-form-item> <el-form-item label="密码:"> <el-input type="password" v-model="password" /> </el-form-item> <el-row> <el-checkbox class="checkBox" v-model="isAgree" label="同意用户使用准则" name="type" /> </el-row> <el-button v-if="isAgree" type="primary" class="loginBtn" @click="login" > 登录 </el-button> </el-form> </el-tab-pane> <el-tab-pane label="注册"> <el-form label-position="right" label-width="100px" style="max-width: 460px" class="loginForm" > <el-form-item label="邮箱:"> <el-input v-model="rEmail" /> </el-form-item> <el-form-item label="密码:"> <el-input type="password" v-model="rPassword" /> </el-form-item> <el-form-item label="确认密码:"> <el-input type="password" v-model="confirmPassword" @blur="confirmFunc" /> </el-form-item> <el-form-item label="验证码:"> <el-row> <el-input type="password" v-model="identifyCode" class="inpWidth" /> <el-button type="primary" @click="getIdentifyCode" plain> 获取验证码 </el-button> </el-row> </el-form-item> <el-row> <el-checkbox class="checkBox" v-model="rAgree" label="同意用户使用准则" name="type" /> </el-row> <el-button v-if="rAgree" type="primary" class="loginBtn" @click="register" > 注册 </el-button> </el-form> </el-tab-pane> </el-tabs> </div></template><script>import { reactive, toRefs } from "@vue/reactivity";import { ElMessage } from "element-plus";export default { setup() { const form = reactive({ Email: "", password: "", isAgree: 0, }); const registerForm = reactive({ rEmail: "", rPassword: "", confirmPassword: "", identifyCode: "", rAgree: 0, }); // 方法 // 登录 function login() { console.log(form); } // 注册 function register() { console.log("注册", registerForm); } // 获取验证码 function getIdentifyCode() { console.log("获取验证码"); } // 确认密码 // function confirmFunc() { // if (registerForm.confirmPassword !== registerForm.rPassword) // alert("密码与确认密码不一致"); // } const confirmFunc = () => { if (registerForm.confirmPassword !== registerForm.rPassword) ElMessage.error("密码与确认密码不一致."); }; return { ...toRefs(form), ...toRefs(registerForm), login, register, getIdentifyCode, confirmFunc, }; },};</script><style scoped>.layout { position: absolute; left: calc(50% - 200px); top: 20%; width: 400px;}.loginBtn { width: 100px;}.loginForm { text-align: center;}.checkBox { margin-left: 7px;}.inpWidth { width: 165px;}</style>
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
- 98
- 99
- 100
- 101
- 102
- 103
- 104
- 105
- 106
- 107
- 108
- 109
- 110
- 111
- 112
- 113
- 114
- 115
- 116
- 117
- 118
- 119
- 120
- 121
- 122
- 123
- 124
- 125
- 126
- 127
- 128
- 129
- 130
- 131
- 132
- 133
- 134
- 135
- 136
- 137
- 138
- 139
- 140
- 141
- 142
- 143
- 144
- 145
- 146
- 147
- 148
- 149
- 150
- 151
- 152
- 153
- 154
- 155
- 156
- 157
- 158
- 159
- 160
- 161
- 162
预览
添加忘记密码弹窗
<template> <div class="layout"> <el-tabs type="border-card"> <el-tab-pane label="登录"> <el-form label-position="right" label-width="60px" style="max-width: 460px" class="loginForm" > <el-form-item label="邮箱:"> <el-input v-model="Email" /> </el-form-item> <el-form-item label="密码:"> <el-input type="password" v-model="password" /> </el-form-item> <el-row> <el-checkbox class="checkBox" v-model="isAgree" label="同意用户使用准则" name="type" /> </el-row> <el-row> <el-button text> <a class="floatR" @click="isChangePassword = true">忘记密码</a> </el-button> </el-row> <el-button v-if="isAgree" type="primary" class="loginBtn" @click="login" > 登录 </el-button> </el-form> </el-tab-pane> <el-tab-pane label="注册"> <el-form label-position="right" label-width="100px" style="max-width: 460px" class="loginForm" > <el-form-item label="邮箱:"> <el-input v-model="rEmail" /> </el-form-item> <el-form-item label="密码:"> <el-input type="password" v-model="rPassword" /> </el-form-item> <el-form-item label="确认密码:"> <el-input type="password" v-model="confirmPassword" @blur="confirmFunc" /> </el-form-item> <el-form-item label="验证码:"> <el-row> <el-input type="password" v-model="identifyCode" class="inpWidth" /> <el-button type="primary" @click="getIdentifyCode" plain> 获取验证码 </el-button> </el-row> </el-form-item> <el-row> <el-checkbox class="checkBox" v-model="rAgree" label="同意用户使用准则" name="type" /> </el-row> <el-button v-if="rAgree" type="primary" class="loginBtn" @click="register" > 注册 </el-button> </el-form> </el-tab-pane> </el-tabs> </div> <!-- 忘记密码弹窗 --> <teleport to="body"> <el-dialog v-model="isChangePassword" title="修改密码" width="40%"> <el-form label-position="right" label-width="100px" style="max-width: 460px" class="loginForm" > <el-form-item label="邮箱:"> <el-input v-model="rEmail" /> </el-form-item> <el-form-item label="密码:"> <el-input type="password" v-model="rPassword" /> </el-form-item> <el-form-item label="确认密码:"> <el-input type="password" v-model="confirmPassword" @blur="confirmFunc" /> </el-form-item> <el-form-item label="验证码:"> <el-row> <el-input type="password" v-model="identifyCode" class="inpWidth" /> <el-button type="primary" @click="getIdentifyCode" plain> 获取验证码 </el-button> </el-row> </el-form-item> <el-row> <el-checkbox class="checkBox" v-model="rAgree" label="同意用户使用准则" name="type" /> </el-row> <el-button v-if="rAgree" type="primary" class="loginBtn" @click="changePassword" > 修改密码 </el-button> <el-button v-if="rAgree" type="primary" class="loginBtn" @click="isChangePassword = false" > 关闭页面 </el-button> </el-form> </el-dialog> </teleport></template><script>import { reactive, toRefs, ref } from "@vue/reactivity";import { ElMessage } from "element-plus";export default { setup() { const form = reactive({ Email: "", password: "", isAgree: 0, }); const registerForm = reactive({ rEmail: "", rPassword: "", confirmPassword: "", identifyCode: "", rAgree: 0, }); // 方法 // 登录 将账号密码写入后台,获取用户数据,后登录 // 需要修改共享数据 function login() { console.log(form); } // 注册 -- 将账号密码写入后台, 自动登录 // 需要修改共享数据 function register() { console.log("注册", registerForm); } // 获取验证码 function getIdentifyCode() { console.log("获取验证码"); } // 确认密码 const confirmFunc = () => { if (registerForm.confirmPassword !== registerForm.rPassword) ElMessage.error("密码与确认密码不一致."); }; // 修改密码 let isChangePassword = ref(false); // 用的是注册参数 function changePassword() {} return { isChangePassword, ...toRefs(form), ...toRefs(registerForm), login, register, getIdentifyCode, confirmFunc, changePassword, }; },};</script><style scoped>.layout { position: absolute; left: calc(50% - 200px); top: 20%; width: 400px;}.loginBtn { width: 100px;}.loginForm { text-align: center;}.checkBox { margin-left: 7px;}.inpWidth { width: 165px;}.floatR { font-size: 10px; margin-left: 9px; color: blue;}</style>
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
- 98
- 99
- 100
- 101
- 102
- 103
- 104
- 105
- 106
- 107
- 108
- 109
- 110
- 111
- 112
- 113
- 114
- 115
- 116
- 117
- 118
- 119
- 120
- 121
- 122
- 123
- 124
- 125
- 126
- 127
- 128
- 129
- 130
- 131
- 132
- 133
- 134
- 135
- 136
- 137
- 138
- 139
- 140
- 141
- 142
- 143
- 144
- 145
- 146
- 147
- 148
- 149
- 150
- 151
- 152
- 153
- 154
- 155
- 156
- 157
- 158
- 159
- 160
- 161
- 162
- 163
- 164
- 165
- 166
- 167
- 168
- 169
- 170
- 171
- 172
- 173
- 174
- 175
- 176
- 177
- 178
- 179
- 180
- 181
- 182
- 183
- 184
- 185
- 186
- 187
- 188
- 189
- 190
- 191
- 192
- 193
- 194
- 195
- 196
- 197
- 198
- 199
- 200
- 201
- 202
- 203
- 204
- 205
- 206
- 207
- 208
- 209
- 210
- 211
- 212
- 213
- 214
- 215
- 216
- 217
- 218
- 219
- 220
- 221
- 222
- 223
- 224
- 225
- 226
- 227
- 228
- 229
- 230
- 231
- 232
- 233
- 234
- 235
预览
已有样式的修改
1.字体大小
首先获取对应选择器
然后修改字体大小
<style>/deep/.el-form-item__label { font-size: 18px !important; font-weight: 900;}/* vue3 中*/:deep(.el-textarea__inner) { min-width: 487px;} </style>
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
结果:
2.默认样式
<style>/* .router-link-active { text-decoration: none; color: blue;} */a { text-decoration: none; color: blue;}</style>
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
亲测效果: