Search code examples
vue.jsquasar

How do you preselect the options when loading the q-select?


I'm new to vue and quasar so i haven't done this yet. I'm building the ability to edit a record and I want to be able to pre select the options for a q-select element. The pre selected options are what the user saved when they first created the record. Currently I have:

<q-select
    v-model="products"
    label="Products *"
    :options="products"
    option-label="title"
    option-value="id"
    multiple
    use-chips
    :rules="[val => val || 'A product is required']"
/>

Solution

  • Chris, You just need to set the model value in your case products and it will work.

    Example -

          model: 'Twitter',
          options: [
            'Google', 'Facebook', 'Twitter', 'Apple', 'Oracle'
          ]
    

    codepen - https://codepen.io/Pratik__007/pen/QWNBxWz