D
D
dron1122021-02-12 12:37:19
Vue.js
dron112, 2021-02-12 12:37:19

How to shorten multiple v-bind?

<Card
  v-for="(flat, idx) of getFlats"
  :key="idx"
  v-bind:title="flat.title"
  v-bind:id="flat.id"
  v-bind:square="flat.square"
  v-bind:price="flat.price"
  v-bind:desc="flat.desc"
  v-bind:phone="flat.phone"
/>

I iterate the component and throw properties into it, how to simplify this entry and get rid of a large number of v-binds?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alex, 2021-02-12
@dron112

If the property names match, then try this:
v-bind="flat"
The result should be equivalent

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question