When we need to add dynamic rules to input fields, such as the one above. When I type a number into mobile phone 2, I need to add validation rules to it

<el-col :span="6"> <el-form-item label=" mobile phone 1:" prop="mobilePhoneOne"> <el-input V-model =" Formareas.mobilePhoneOne" Size ="mini"></el-input> </el-col> < EL-col :span="6"> <el-form-item label=" mobile phone 2:" prop="mobilePhoneTwo">  <el-input v-model="formAreas.mobilePhoneTwo" size="mini"></el-input> </el-form-item> </el-col>Copy the code

Simply change the required value of the validation rule for Formareas.MobilePhoneTwo to false, and it will automatically add the validation rule

MobilePhoneOne: [{required: true, message: "Please enter phone number ", trigger: "blur",}, {pattern: / ^ 1 [3 4 5 6 7 | | | | | | 8, 9] [0-9] \ d {8} $/, the message: "please enter the correct phone number," trigger: [" blur ", "change"],},], mobilePhoneTwo: [{required: False, the message: "please enter the phone number," trigger: "blur"}, {pattern: / ^ 1 [3 4 5 6 7 | | | | | | 8, 9] [0-9] \ d {8} $/, the message: "Please enter the correct phone number ", trigger: ["blur", "change"],},],Copy the code

For more details, see Element’s website