el-form-item 里面有多个select 或者input :
<el-form-item label="选项一:" required> <div class="diasubject"> <el-form-item prop="stage.code" :rules="[{ required: true, message: '请选择', trigger: 'change' }]"> <el-select v-model="Newtextbooks.cinfigForm.stage" placeholder="请选择" value-key="code"> <el-option v-for="item in diaFormQArr.stageArr" :key="item.code" :label="item.name" :value="item"> </el-option> </el-select> </el-form-item> <el-form-item prop="subject.code" :rules="[{ required: true, message: '请选择', trigger: 'change' }]"> <el-select v-model="Newtextbooks.cinfigForm.subject" placeholder="请选择" value-key="code" disabled> <el-option v-for="item in diaFormQArr.subjectArr" :key="item.code" :label="item.name" :value="item"> </el-option> </el-select> </el-form-item> </div> </el-form-item>
当select 选中值绑定为对象时,el-form-item 上面的prop 只需要 监听 select 的 v-model 绑定的 stage对象里面某个属性是否有值,这样就可以验证必填