My JS array is structured like this:
[{type:'text', data: 'some text'},{type: 'image', data: 'link/to/image'}]
Each value of type
corresponds to a different Vue component (<text-block>
, <image-block>
). I want to use a v-for
loop to iterate over this array and dynamically create the appropriate Vue component based on the type.
Most examples of v-for
demonstrate creating multiple instances of the same element, such as multiple <li>
elements. Is there a method to generate different elements within a v-for
loop?