Giter Club home page Giter Club logo

Comments (2)

desislavsd avatar desislavsd commented on August 13, 2024

@signmeuptwice I am sorry you are having hard time with the documentation. Definitely going to improve the corresponding sections.

So the problem here is related to the as property. It takes place when you are working with non primitive options as with the [ {label:'2000', value:2000 }, {label:'2001', value:2001 },etc...] in your example. The as property is expected to be an array of exactly 3 strings (paths): [ label, value, index ]. Where:

  • label is the path to the property of your option object i.e {label:'2000', value:2000} which should be used as a display value and also in filtering. It also is the property to which the query will be set when creating new option in tagging mode.
  • value path is to the property that should be set as model value when an option is selected; if the path is an empty string, the whole object will be assigned to the model.
  • index path is very important. It should point to a unique primitive value for each option and is applied as :key in the internal v-for of the options list. It is also used when comparing two options objects e.g. for detecting if an option is selected or not. Therefore it cannot be some random generated value and is important for the end user to have control over it. Usually you would pass a path that points to the option's id.

Some possible values would be: :as="['label', 'value', 'id']", :as="['label', '', 'id']".

As this is quite verbose it is supported to pass these paths as a simple : separated string: as="label:value:id" and as="label::id" respectively.

That said, for your particular example the :as="'label::value'" is correct and should be working just fine. But if you get duplicate key error it means you have two or more options with the same value which in fact should be something you did not intend and in which case the plugin actually helped you spot an error in your data ;)

from vue-select.

signmeuptwice avatar signmeuptwice commented on August 13, 2024

@desislavsd thank you for the detailed explanation; you were right I had a duplicate in my data but I am still glad I asked because now It is a lot clearer to me.
I did not realise that :: was just and empty second value and therefore providing an index.
You should definitely copy/paste this answer in your doc :)
And thank you for the great work, this component is really good; does it all in a very nice way; neat !

from vue-select.

Related Issues (14)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.