表单验证

This commit is contained in:
xing 2020-06-16 11:05:37 +08:00
parent 38e1cfd450
commit 13d6786499

View File

@ -4,11 +4,11 @@
<div class="avatar"> <div class="avatar">
<img src="../assets/logo.png" alt="logo"> <img src="../assets/logo.png" alt="logo">
</div> </div>
<el-form class="login-from" :model="loginForm"> <el-form class="login-from" :rules="loginFormRules" :model="loginForm">
<el-form-item label=""> <el-form-item prop="username" label="">
<el-input v-model="loginForm.username" prefix-icon="iconfont icon-user"></el-input> <el-input v-model="loginForm.username" prefix-icon="iconfont icon-user"></el-input>
</el-form-item> </el-form-item>
<el-form-item label=""> <el-form-item prop="password" label="">
<el-input v-model="loginForm.password" type="password" prefix-icon="iconfont icon-3702mima"></el-input> <el-input v-model="loginForm.password" type="password" prefix-icon="iconfont icon-3702mima"></el-input>
</el-form-item> </el-form-item>
<el-form-item class="btns"> <el-form-item class="btns">
@ -28,6 +28,16 @@ export default {
loginForm: { loginForm: {
username: '', username: '',
password: '' password: ''
},
loginFormRules: {
username: [
{ required: true, message: '请输入登录名称', trigger: 'blur' },
{ min: 3, max: 10, message: '长度在 3 到 10 个字符', trigger: 'blur' }
],
password: [
{ required: true, message: '请输入登录密码', trigger: 'blur' },
{ min: 6, max: 15, message: '长度在 6 到 15 个字符', trigger: 'blur' }
]
} }
} }
} }