[Vuejs]-Vue: How to use variable as array key in component binding

2👍

Your array currently contains only one object, with multiple nested objects. It should be:

items: [
            {
               default: {
                  title: 'Title 1 for default settings',
               },
               guest: {
                  title: 'Title 1 for guest settings'
               }
            },
            {
               default: {
                  title: 'Title 2 for default settings',
               },
               guest: {
                  title: 'Title 2 for guest settings'
               }
            }
      ]

With this the following should work:

<my-component v-for="item in items"
    :title="item[componenttype].title"
/>

1👍

You are making componenttype into a string by doing :title="item['componenttype'].title".
Just do :title="item[componenttype].title"

Also check your array syntax, there might be some mistakes there

👤Marton

Leave a comment