Javascript 如何使用yup.lazy使表单方案动态?
我的问题是我有一个依赖于另一个域的域。这是关于字段:“类型”,如果该字段有某个值,那么我想将字段“阶段”设置为不再需要。我的代码:Javascript 如何使用yup.lazy使表单方案动态?,javascript,reactjs,typescript,formik,yup,Javascript,Reactjs,Typescript,Formik,Yup,我的问题是我有一个依赖于另一个域的域。这是关于字段:“类型”,如果该字段有某个值,那么我想将字段“阶段”设置为不再需要。我的代码: const schema = Yup.object().shape({ isDefault: Yup.boolean(), plugs: Yup.array() .ensure() .of( Yup.object().shape({ id: Yup.number().nullable(), type
const schema = Yup.object().shape({
isDefault: Yup.boolean(),
plugs: Yup.array()
.ensure()
.of(
Yup.object().shape({
id: Yup.number().nullable(),
type: Yup.string().required(),
kw: Yup.number().nullable().required(),
phase: Yup.number().nullable().required(),
ampere: Yup.number().nullable().required(),
position: Yup.string().nullable().required(),
maxDefaultSoc: Yup.number().nullable(),
maxVoltage: Yup.number().nullable(),
onlyCP1PhaseAmpere: Yup.number().nullable(),
onlyCP1PhaseKw: Yup.number().nullable(),
efficiencyCharging: Yup.number().nullable(),
})
),
})
我该怎么做