Vue-select: Error if options array objects doesn't contain 'label' property

Created on 9 Mar 2017  路  12Comments  路  Source: sagalbot/vue-select

I know that it is written in the documentation that, if the options array is composed by object the v-select by default searches for a property called 'label', but in my opinion it should not return an error and break the rendering. At least a warning and display nothing as label.
Now it throws an error and break the execution if the property 'label' is not present in the objects inside the options array.

I had this:

    var options = [
                { name :'Giardino e terrazzo',
                       slug:'giardino'
                },
                { name: 'Cucina e piatti',
                        slug:'cucina'
                 },
                { name: 'Vernici e tinture',
                        slug:'vernici'
                }
    ];

and it returned this error
schermata 2017-03-09 alle 16 25 51

add added a property 'label' to each object and everything worked fine.
Don't you think the component should not break?

enhancement question

Most helpful comment

The error is not about the options you provide but the "v-model" you provide.
If the object you use in v-model is an empty object, you get this error.
You can change it to "null" in order to dismiss the error.
I hope it also helps to fix this bug in the source code.

All 12 comments

Yes, I can certainly make it degrade a little more gracefully. I've added a couple lines to make sure the key actually exists, and if it doesn't, filtered options will return an empty array, and you'll get this console warning:

Graceful Degredation

It'll be updated in the next release. Thanks for the input!

Fixed in v2.0.1.

I encounter this warning in version 2.6.0

@gronel can you post a reproduction link?

package.json
image

component
image

warning
image

option:[{printerName:"xxxx", ID:1}, {printerName:"xxx2",ID:2}]

get the same warning, how do I solve it, please

getting the same warning...

@rcaac @ahmatovicm can you provide the version you are using and ideally a reproduction?

"vue-select": "^2.6.4"

The error is not about the options you provide but the "v-model" you provide.
If the object you use in v-model is an empty object, you get this error.
You can change it to "null" in order to dismiss the error.
I hope it also helps to fix this bug in the source code.

The error is not about the options you provide but the "v-model" you provide.
If the object you use in v-model is an empty object, you get this error.
You can change it to "null" in order to dismiss the error.
I hope it also helps to fix this bug in the source code.

I can confirm this works... thanks @askanhan

thanks @askanhan

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ducdev picture ducdev  路  3Comments

twz915 picture twz915  路  3Comments

jluterek picture jluterek  路  3Comments

PrimozRome picture PrimozRome  路  4Comments

lau-a picture lau-a  路  3Comments