我正在使用vue-multiselect像这样:
<multiselect
id="customer_last_name_input"
v-model="value"
:options="activeUserProfiles"
label="lastname"
placeholder="Select or search for an existing customer"
track-by="uid"
:close-on-select="true"
@select="onSelect"
@remove="onRemove"
:loading="isLoading"
:custom-label="customerSelectName"
aria-describedby="searchHelpBlock"
selectLabel=""
>
...从数组中获取活跃客户列表,然后在一个不错的选择菜单中提供它们。
这很好用。但是,我需要从另一个资源(称为customerNone
)添加另一个选项到options
道具,但数据作为对象返回,如下所示:
{"uid":1,"lastname":"None Given","firstname":"User","email":null,"phone":null...blah}
vue-multiselect 文档声明:option
道具必须是一个数组。
问题:我在 vue-multiselect 组件中处理这个问题的最佳方法是什么?这是我试图帮助解释我正在尝试做的事情(不确定这是否是处理它的最佳方法)。不幸的是,我的尝试导致控制台错误(见下文):
我正在传递一个名为的道具noCustomer
,如果是true
,我需要在以下位置使用customerNone
配置文件:options
:
<multiselect
:options="noCustomer ? customerNone : getActiveUserProfiles"
>
这是错误:
Invalid prop: type check failed for prop "options". Expected Array, got Object
有没有办法可以将对象转换为customerNone
对象数组?谢谢!