Answer the question
In order to leave comments, you need to log in
How to dynamically call only those component props that are needed?
Hello. There is v-for, it generates components from an array of objects.
If there is a mask, we refer to its properties, otherwise these properties are unnecessary to us.
How to dynamically generate props for a component?
<v-col v-for="item of components_list" v-bind:key="item.id">
<v-text-field
v-model="components[item.code_name]"
:label="item.title"
// Эти свойства нужны только когда есть маска, в других случаях их не вызывать
v-mask="item.mask"
:hint="item.mask"
/>
</v-col>
Answer the question
In order to leave comments, you need to log in
If you don’t need any props, then pass falsely values to them and already inside the component determine what is in your props and what to do with it
The correct answer was given by Andrey Suha .
But if you really want to, then you can do something like this:
<v-col v-for="item of components_list" v-bind:key="item.id">
<v-text-field
v-bind="getProps(item)"
v-model="components[item.code_name]"
/>
</v-col>
where getProps
returns an object of the form { [prop]: value }
.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question