我必须修复发送表单时丢失一些数据的错误。我有这个typescript接口
_id: string
name: string
coords?: number[]
createdAt?: Date
updatedAt?: Date
deletedAt?: Date
}
这些是我的道具:
props: {
data: {
type: Object as PropType<Location>,
default: () => ({
_id: null,
name: '',
createdAt: '',
updatedAt: ''
})
}
},
,这就是我创建v-model的方法:
const location = reactive({ ...props.data } as Location)
const rules = {
name: { required },
coords: { required }
}
const v$ = useVuelidate(rules, location)
我有一个像这样的错误
Types of property 'name' are incompatible.
Type 'string' is not assignable to type 'Ref<any>'.
76 | coords: { required }
77 | }
> 78 | const v$ = useVuelidate(rules, location)
由于规则需要设置属性,因此可以为其设置默认值或删除Location接口中的可选属性