1.html 代码
<a-form-model-item ref='isSightseeingGrape' prop='isSightseeingGrape' :colon='false'
style='margin-top: 10px; font-size: 18px; font-weight: 600'>
<div style='clear: both;margin-top: 10px; font-size: 18px; font-weight: 600'>
<div style='float: left'>4.是否观光采摘葡萄园?:</div>
</div>
<div style='clear: both;height:5px;'></div>
<div style='float: left;margin-left: 4px; font-size: 18px; font-weight: 400'>
<a-radio-group v-model='parkFormItem.isSightseeingGrape'
>
<!-- 栽种类型 0 露地栽培 1设施栽培-->
<a-radio class='radio-border-left' style='float: left;' value='1'>
是
</a-radio>
<a-radio class='radio-border-left' style='float: left;' value='2'>
否
</a-radio>
</a-radio-group>
</div>
</a-form-model-item>
2.校验对象
parkFormItem: {
isSightseeingGrape: undefined,
},
3.校验规则对象
parkFormRules: {
addressDetail: [{ required: true, message: '请选择详细地址!', trigger: 'change' }],
isSightseeingGrape: [{ required: true, message: '请选择是否观光采摘葡萄园!', trigger: 'change' }],
cultivateType: [{ required: true, message: '请选择葡萄园的栽培类型!', trigger: 'change' }],
},
校验触发方式失效,如下图赋值后,校验依旧存在
解决方法:
将 1 的html对象 中前面的块状标签 移到 <a-form-model-item> 前面去
<div style='clear: both;margin-top: 10px; font-size: 18px; font-weight: 600'>
<div style='float: left'>4.是否观光采摘葡萄园?:</div>
</div>
<div style='clear: both;height:5px;'></div>
<a-form-model-item ref='isSightseeingGrape' prop='isSightseeingGrape' :colon='false'
style='margin-top: 10px; font-size: 18px; font-weight: 600'>
<div style='float: left;margin-left: 4px; font-size: 18px; font-weight: 400'>
<a-radio-group v-model='parkFormItem.isSightseeingGrape'
>
<!-- 栽种类型 0 露地栽培 1设施栽培-->
<a-radio class='radio-border-left' style='float: left;' value='1'>
是
</a-radio>
<a-radio class='radio-border-left' style='float: left;' value='2'>
否
</a-radio>
</a-radio-group>
</div>
</a-form-model-item>
思路解析:
校验方式 貌似只对
a-form-model-item 标签下的第一个块级元素中的对象起作用