mirror of
https://github.com/tenrok/vue-select.git
synced 2026-06-22 10:30:34 +03:00
Update props.md (#839)
This commit is contained in:
+32
-32
@@ -144,15 +144,18 @@ label: {
|
|||||||
},
|
},
|
||||||
```
|
```
|
||||||
|
|
||||||
## index
|
## reduce
|
||||||
|
|
||||||
Tells vue-select what key to use when generating option
|
When working with objects, the reduce
|
||||||
values when each `option` is an object.
|
prop allows you to transform a given
|
||||||
|
object to only the information you
|
||||||
|
want passed to a v-model binding
|
||||||
|
or @input event.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
index: {
|
reduce: {
|
||||||
type: String,
|
type: Function,
|
||||||
default: null
|
default: option => option,
|
||||||
},
|
},
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -168,24 +171,20 @@ display, you should use the `option` and
|
|||||||
|
|
||||||
```js
|
```js
|
||||||
getOptionLabel: {
|
getOptionLabel: {
|
||||||
type: Function,
|
type: Function,
|
||||||
default(option) {
|
default(option) {
|
||||||
if (this.index) {
|
if (typeof option === 'object') {
|
||||||
option = this.findOptionByIndexValue(option);
|
if (!option.hasOwnProperty(this.label)) {
|
||||||
}
|
return console.warn(
|
||||||
|
`[vue-select warn]: Label key "option.${this.label}" does not` +
|
||||||
if (typeof option === "object") {
|
` exist in options object ${JSON.stringify(option)}.\n` +
|
||||||
if (!option.hasOwnProperty(this.label)) {
|
'http://sagalbot.github.io/vue-select/#ex-labels'
|
||||||
return console.warn(
|
)
|
||||||
`[vue-select warn]: Label key "option.${this.label}" does not` +
|
}
|
||||||
` exist in options object ${JSON.stringify(option)}.\n` +
|
return option[this.label]
|
||||||
"http://sagalbot.github.io/vue-select/#ex-labels"
|
}
|
||||||
);
|
return option;
|
||||||
}
|
}
|
||||||
return option[this.label];
|
|
||||||
}
|
|
||||||
return option;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -294,14 +293,15 @@ User defined function for adding Options
|
|||||||
|
|
||||||
```js
|
```js
|
||||||
createOption: {
|
createOption: {
|
||||||
type: Function,
|
type: Function,
|
||||||
default(newOption) {
|
default(newOption) {
|
||||||
if (typeof this.optionList[0] === "object") {
|
if (typeof this.optionList[0] === 'object') {
|
||||||
newOption = { [this.label]: newOption };
|
newOption = {[this.label]: newOption}
|
||||||
}
|
}
|
||||||
this.$emit("option:created", newOption);
|
|
||||||
return newOption;
|
this.$emit('option:created', newOption)
|
||||||
}
|
return newOption
|
||||||
|
}
|
||||||
},
|
},
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user