0

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?

0

1 Answer 1

2

I think all you need is

<component v-bind="object"/>

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

Sign up to request clarification or add additional context in comments.

2 Comments

can you elaborate on this? Then in component you will have props named as per object keys.
@PA-GW well, if you have object like this: {a: b} and pass it to the v-bind you will be able to access it inside component by calling this.a. No more code needed AFAIK.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.