Vue アプリで vue-select を使用しています。v-select のラッパーとしてコンポーネントを作成しました。options 配列の特定の列のみを返すには、vue-select の :reduce prop を使用します。
<template>
<span>
<label v-if="title">{{title}}</label>
<v-select
:options="options"
:label="label"
:placeholder="placeholderText"
:close-on-select="closeOnSelectValue"
:disabled="isDisabled"
:multiple="multiple"
:value="value"
@input="handleInput($event)"
:loading="isLoading"
:reduce="option=> option.val"
></v-select>
</span>
val
このコードは機能しますが、静的文字列を動的 prop にしたいと考えていますreturnKey
。これは prop としてコンポーネントに渡されます。
props: {
returnKey: {
type: String,
default: null,
},
}
これを機能させるには、:reduce に渡される関数で 'option' 文字列と 'returnKey' の動的な値を組み合わせるには、どの構文を使用すればよいですか?