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'}
          ]
        }],
})

https://blog.csdn.net/PlanetWalk/article/details/130616002

posted @ 2023-11-09 09:13  寒冷的雨呢  阅读(188)  评论(0编辑  收藏  举报