Q-Select options from object



  • Hello,

    I am making one select which is getting its options by one custom object instead of an array of strings.
    I made it work but I can’t get why it is working.

    Options array

    treatmentCatsData = [{ id: 1, cat: 'cat1' }, { id: 2, cat: 'cat2' } ]
    

    Not working template

    <q-select
      v-model="treatmentCat"
      :options="treatmentCatsData"
      :option-value="id"
      :option-label="cat"
      label="Categoria di trattamento"
      name="treatmentCat"
      emit-value
      map-options
    ></q-select>
    

    Working template

    <q-select
      v-model="treatmentCat"
      :options="treatmentCatsData"
      :option-value="'id'"
      :option-label="'cat'"
      label="Categoria di trattamento"
      name="treatmentCat"
      emit-value
      map-options
    ></q-select>
    

    As per documentation here, I should the html properties “option-value” and “option-label” should accept the object properties names, not strings representing the object property name.

    Am I misunderstanding something?


Log in to reply