我最近开始与 Yup 合作,我的项目中有这个架构,我需要将参数从字符串更改为对象 {string, string}它是如何(正在工作):exports.schema = yup.object().shape({ destination: yup.string().required('required msg'), .....})我想成为的样子:exports.schema = yup.object().shape({destination: yup.object().shape({ name: string().required('required msg'), id: string().default(null).nullable() }).required('required msg'),....})但是在我更改对象后,我一直收到此错误:参考错误:未定义字符串我做错了什么?
2 回答

慕的地6264312
TA贡献1817条经验 获得超6个赞
你错过了字符串之前
exports.schema = yup.object().shape({
destination: yup.object().shape({
name: yup.string().required('required msg'),
id: yup.string().default(null).nullable()
}).required('required msg'),
....
})
添加回答
举报
0/150
提交
取消