form表单 数组中对象校验 深度校验
<el-form ref="dataFormRef" :model="form" :rules="dataRules" formDialogRef label-width="100px" v-loading="loading">
<el-form-item label="负责人" prop="directorName">
<el-input v-model="form.directorName" placeholder="请输入负责人"/>
</el-form-item>
<el-form-item label="项目名称" prop="projectVO.projectName">
<el-input v-model="form.projectVO.projectName" placeholder="请输入项目名称"/>
</el-form-item>
<el-form-item label="规格:" prop="res.0.standards">
<el-input v-model="goods.res[0].standards" placeholder="规格"></el-input>
</el-form-item>
</el-form>
// 定义校验规则
const dataRules = ref({
directorName: [{ required: true, message: '请填写负责人', trigger: 'blur' }],
projectVO: {
projectName:[{ required: true, message: '申请项目不能为空', trigger: 'blur' }]
},
res: [{
standards: [
{required: true, message: '请输入规格', trigger: 'blur'},
{min: 1, max: 200, message: '长度在 10 到 200 个字符', trigger: 'blur'}
],
serve: [
{required: true, message: '请输入服务', trigger: 'blur'},
{min: 1, max: 200, message: '长度在 10 到 200 个字符', trigger: 'blur'}
]
}],
})
择善人而交,择善书而读,择善言而听,择善行而从。