问题描述:添加select校验一直不触发校验函数,dom如下:
<el-form-item
prop="clause"
id="clause"
>
<el-select
v-model="form.clause"
placeholder="请选择"
value-key="code"
style="width:150px;"
@change="watchDocParamsChange"
>
<el-option
v-for="item in clauseArray"
:key="item.code"
:label="item.name"
:value="item"
/>
</el-select>
</el-form-item>
校验规则应该如下:
data () {
return {
// 表单校验规则
rules: {
clause: [{ type: 'object', required: true, fields: { code: { type: 'string',
required: true, trigger: 'change', message: 'xxxx不可为空' } } }],
},
clauseArray: [
{ name: 'xxx', code: '1' },
{ name: 'xxx', code: '2' }
],
}
}