michaelamting
michaelamting

Reputation: 11

Vue: How to pass multiple Props with a loop

I have an Object with multiple properties.

And i want to pass this multiple Props in my component. Usually i know which props i want to pass and do it like this:

<component :prop1="object.prop1" :prop2="object.prop2" :prop3="object.prop3" />

But i want to pass the props without knowing how much props there are in my JSON Object. Like a loop:

<component :loopThroughMyProps="object" />

So that i get the same result. Is there any possibility to achieve this?

Upvotes: 0

Views: 428

Answers (1)

m.cichacz
m.cichacz

Reputation: 749

I think all you need is

<component v-bind="object"/>

Then in component you will have props named as per object keys.

Upvotes: 2

Related Questions