业务场景:当select=A时 C非必填 反之当select=B时C必填
代码实现
<el-form-item label="支付方式 :" :rules="[{ required: true, message: '请选择支付方式', trigger: 'change' }]" prop="couponBatchPaytype">
<el-select @change="changeCouponBatchPaytype" clearable v-model="ruleForm.couponBatchPaytype" placeholder="请选择支付方式" style="width:30%">
<el-option label="明点转账" value="0"></el-option>
<el-option label="暗点抵扣" value="1"></el-option>
</el-select>
</el-form-item>
<el-form-item label="选择客户:" prop="custrelCode" :rules="ruleForm.couponBatchPaytype == 1 ? rules.custrelCode : [{ required: false }]">
<el-select @change="ysMakeActive" v-model="value2" value-key="userinfoCode" style="width:30%" placeholder="请选择客户" clearable>
<el-option v-for="item in userArr2" :key="item.userinfoCode" :label="item.userinfoCompname" :value="item"> </el-option>
</el-select>
</el-form-item>
data部分
rules: {
custrelCode: [{ required: true, message: '请选择客户', trigger: 'change' }],
},