Qselect array structure



  • Hi everybody!
    Is there a simple way to get work Qselect with an array like this,
    [ {id: 1, title: ‘title1’}, {id: 2, title: ‘title2’} ]
    and not the suggested one
    [
    {
    label: ‘Google’,
    value: ‘goog’
    },
    {
    label: ‘Facebook’,
    value: ‘fb’
    }
    ]



  • Hi. No.

    You should modify your array for displaying in the q-select
    Note: value does not have to be a string. So considering your example and assuming you want the whole object as the value:

    data () {
      return {
        options: [].// formated options array
        value: [] // array of selected values
      }
    },
    mounted () {
      // get options during mouted function
      axios.get('/path')
        .then(response => {
         this.options = response.data.map(item => {
            return {
              label: item.title,
              value: item  // assign whole object as value. Could be anything
            }
          })
        })
    }