表单中单独给一个input进行验证

1.在el-form-item 里写:rules 验证规则
2.在el-form-item 里写prop 属性 其值 和v-model 一致但是要去掉表单对象字段----prop=“a” ; v-model=“form.a”
3.如果进行数字验证 v-model 要写成 v-model.number

 <el-form-item label="RATING:" :rules="[{ type: 'number', message: 'Must be a numeric value'},{ pattern:/^([1-9]|[1-9]\\d|100)$/, message: 'Please enter a value of 1-100', trigger: 'blur' }]" prop='creditRating.localRiskScoreCode'>
                    <el-col :span="8">
                      <el-input v-model.number="financialDataItemInfoForm.creditRating.localRiskScoreCode"  placeholder="Please enter a value of 1-100" ></el-input>
                    </el-col>
                  </el-form-item>

你可能感兴趣的:(web前端)