Home > other >  Multiselect component label as number
Multiselect component label as number

Time:11-01

I am using this component https://github.com/vueform/multiselect

<Multiselect :options="testData" label="name"/>
 const testData = computed(() => {
      return [
        { name: 'Vue.js', id: 'vue' },
        { name: 'Angular', id: 'angular' }
      ]
 })

return { testData }

The label have to be a property from an object. Anyone knows, if it's possible for the label to look like 1, 2 instead of Vue.js, Angular? I want the label to be displayed as numbers. Like index 1

CodePudding user response:

Use map on the array:

...
[...].map((value, index) => {
  return {
    name: value.name,
    id: index 1
  }
})
...

Check this example

  • Related