优化目标 和 目标转化出价必填的 切换的时候还会隐藏掉 这时候的if语句会导致rules判断失效
我的办法是把判断拉到外面 别放在el-form-item里
<section v-if="unitForm.baseTarget === 'OCPM' && unitForm.cpaTargetOptions !== undefined && unitForm.cpaTargetOptions.length > 0">
<el-form-item prop="cpaTarget" label="优化目标" required>
<el-select
style="width: 300px;"
v-model="unitForm.cpaTarget"
placeholder="请选择优化目标"
clearable
@change="(value)=>changeCpaTarget(value)"
>
<el-option
v-for="item in unitForm.cpaTargetOptions"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</el-form-item>
</section>
rules: {
cpaTarget: [
{ required: true, message: '请选择优化目标', trigger: 'change' }
],
}