我被困在VueFormulate上了,特别是我想要从<FormulateInput type="select" name="products">组件中填充一个数组。这个想法应该是,每次您选择一个选项时,该选项应该进入绑定到<FormulateForm v-model="user">的模型的<FormulateForm v-model="user">数组中,而products只是变成一个基本整数而不是数组。
让我向你展示一些证监会的代码。
<template>
<FormulateForm v-model="user" name="example" @submit="performSomething">
<!-- Other fields working fine !-->
<FormulateInput
type="select"
name="products"
:label="$t('form.inputs.products.label')"
:placeholder="$t('form.inputs.products.placeholder')"
:options="products.map(p => ({ label: p.name, value: p.id }))"
/>
</Formulateform>
</template>props: {
products: Array
}
// User model bound to Formulateform
data: () => ({
user: {
name: "",
description: "",
products: [], // This should be populated by the select box
},
}),预期的行为应该是,user.products从每个输入的select中获得ID,但它只是将数组替换为first select的ID。当然,我遗漏了一些东西,但我不明白,文档的确提到每个FormulateInput都有一个@input事件,但是我不能使用它,因为偶数本身只触发一次,然后我只得到FormulateForm事件
发布于 2020-11-18 15:18:24
原来是我的错,多么令人惊讶。关于解决方案的更多信息,在这里:https://github.com/wearebraid/vue-formulate/issues/318
https://stackoverflow.com/questions/64892194
复制相似问题