Vee-validate的USEFieldArray仅与解构一起使用
对所有人来说,美好的一天,
有人可以向我解释为什么Vee-validates useFieldArray
才能在我解构时正确工作吗?
模板:
// For the working example I use "fields" instead of fieldArray.fields.
// Nothing more, nothing less
<div v-for="(field, idx) in fieldArray.fields"
class="d-flex justify-content-between align-items-center">
<div>
<FormControl :id="`${props.type}[${idx}].name`"></FormControl>
</div>
<div>
<Checkbox :id="`${props.type}[${idx}].value`"></Checkbox>
</div>
</div>
工作:
const form = useForm({initialValues: {[props.type]: getInitialFormValues()}});
const {fields, push} = useFieldArray(props.type)
不工作:
const form = useForm({initialValues: {[props.type]: getInitialFormValues()}});
const fieldArray = useFieldArray(props.type)
谢谢您!
Good day to all,
can someone explain me why vee-validates useFieldArray
only works correctly when I deconstruct it?
Template:
// For the working example I use "fields" instead of fieldArray.fields.
// Nothing more, nothing less
<div v-for="(field, idx) in fieldArray.fields"
class="d-flex justify-content-between align-items-center">
<div>
<FormControl :id="`${props.type}[${idx}].name`"></FormControl>
</div>
<div>
<Checkbox :id="`${props.type}[${idx}].value`"></Checkbox>
</div>
</div>
Working:
const form = useForm({initialValues: {[props.type]: getInitialFormValues()}});
const {fields, push} = useFieldArray(props.type)
Not working:
const form = useForm({initialValues: {[props.type]: getInitialFormValues()}});
const fieldArray = useFieldArray(props.type)
Thank you in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想,如果您不解构对象,则需要包装值()。
尝试此
更改为
(对于Vue&gt; = 3)
I guess, you need wrap values to ref(), if you do not deconstruct object.
Try this
change to
(for vue >= 3)