Skip to content

Commit 0ea9514

Browse files
authored
Update props.md (sagalbot#839)
1 parent 90605bd commit 0ea9514

File tree

1 file changed

+32
-32
lines changed

1 file changed

+32
-32
lines changed

docs/api/props.md

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -144,15 +144,18 @@ label: {
144144
},
145145
```
146146

147-
## index
147+
## reduce
148148

149-
Tells vue-select what key to use when generating option
150-
values when each `option` is an object.
149+
When working with objects, the reduce
150+
prop allows you to transform a given
151+
object to only the information you
152+
want passed to a v-model binding
153+
or @input event.
151154

152155
```js
153-
index: {
154-
type: String,
155-
default: null
156+
reduce: {
157+
type: Function,
158+
default: option => option,
156159
},
157160
```
158161

@@ -168,24 +171,20 @@ display, you should use the `option` and
168171

169172
```js
170173
getOptionLabel: {
171-
type: Function,
172-
default(option) {
173-
if (this.index) {
174-
option = this.findOptionByIndexValue(option);
175-
}
176-
177-
if (typeof option === "object") {
178-
if (!option.hasOwnProperty(this.label)) {
179-
return console.warn(
180-
`[vue-select warn]: Label key "option.${this.label}" does not` +
181-
` exist in options object ${JSON.stringify(option)}.\n` +
182-
"http://sagalbot.github.io/vue-select/#ex-labels"
183-
);
184-
}
185-
return option[this.label];
186-
}
187-
return option;
188-
}
174+
type: Function,
175+
default(option) {
176+
if (typeof option === 'object') {
177+
if (!option.hasOwnProperty(this.label)) {
178+
return console.warn(
179+
`[vue-select warn]: Label key "option.${this.label}" does not` +
180+
` exist in options object ${JSON.stringify(option)}.\n` +
181+
'http://sagalbot.github.io/vue-select/#ex-labels'
182+
)
183+
}
184+
return option[this.label]
185+
}
186+
return option;
187+
}
189188
},
190189
```
191190

@@ -294,14 +293,15 @@ User defined function for adding Options
294293

295294
```js
296295
createOption: {
297-
type: Function,
298-
default(newOption) {
299-
if (typeof this.optionList[0] === "object") {
300-
newOption = { [this.label]: newOption };
301-
}
302-
this.$emit("option:created", newOption);
303-
return newOption;
304-
}
296+
type: Function,
297+
default(newOption) {
298+
if (typeof this.optionList[0] === 'object') {
299+
newOption = {[this.label]: newOption}
300+
}
301+
302+
this.$emit('option:created', newOption)
303+
return newOption
304+
}
305305
},
306306
```
307307

0 commit comments

Comments
 (0)