猿问

是的:字符串未定义

我最近开始与 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'),

....

})

但是在我更改对象后,我一直收到此错误:


参考错误:未定义字符串


我做错了什么?


陪伴而非守候
浏览 195回答 2
2回答

慕的地6264312

你错过了字符串之前exports.schema = yup.object().shape({destination: yup.object().shape({    name: yup.string().required('required msg'),    id: yup.string().default(null).nullable()  }).required('required msg'),....})
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答