我用的是Vue 3和vee-validate@4
我想使用setFieldValue方法来设置branding.name的值,但是我似乎不能这样做。
该方法使用Typescript's keyof验证参数。
const { setFieldValue } = useForm({
validationSchema: Yup.object({
branding: Yup.object({
name: Yup.string().required(),
})
)}
)}
// Examples:
setFieldValue('branding.name', null) // Not Working
// I can use only the "first item"
setFieldValue('branding', null) // It makes sense but doesn't work (because `branding` is an object and not a field)<!-- This is a custom component -->
<InputField id="branding.name" />我该怎么做?
发布于 2022-02-24 15:27:25
我为同样的问题而挣扎。事实证明,这很简单。只要嵌套任何js对象就行了。
setFieldValue({
branding: {
name: 'your typed value'
}
})https://stackoverflow.com/questions/70991472
复制相似问题