表单验证

1.

 formRules: {         newPassword: [           { required: true, message: '请输入新密码', trigger: 'blur' }         ],         oldPassword: [           { required: true, message: '请输入当前密码', trigger: 'blur' }         ],         retypePassword: [           { required: true, validator: validateRetypePassword, trigger: 'blur' }         ]       }, 2.  <el-form ref="passwordForm" :model="formData" label-width="110px" :rules="formRules" class="user-form">             <el-form-item label="当前密码" prop="oldPassword">               <el-input show-password v-model="formData.oldPassword"></el-input>             </el-form-item> </el-form> 3.  data() {     var validateRetypePassword = (rule, value, callback) => {       if (value === '') {         callback(new Error('请再次输入新密码'))       } else if (value !== this.formData.newPassword) {         callback(new Error('两次输入的密码不一致!'))       } else {         callback()       }     } }
上一篇:Authentication is required to set the network proxy


下一篇:Element-ui中form组件的校验规则