I
I
Ilya2020-02-21 11:14:00
Vue.js
Ilya, 2020-02-21 11:14:00

How to render this in a Vue template?

You need to get a table with the following columns:
Plan|Result|Deviation|Plan|Result|Deviation|Plan|Result|Deviation|Plan|Result|Deviation|

That is, the columns "plan", "result", "deviation" are repeated many times.
Single clear how to do:

<tr>
  <td v-for="n in 30">План</td>
</tr>

And how to make the necessary loop for my task in the Vue template?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
0
0xD34F, 2020-02-21
@Rimush

data: () => ({
  columns: [ 'aaa', 'bbb', 'ccc' ],
  repeat: 5,
}),
computed: {
  repeatedColumns() {
    return Array(this.repeat).fill(this.columns).flat();
  },
},

<td v-for="n in repeatedColumns">{{ n }}</td>

A
Alex, 2020-02-21
@Kozack Vue.js

Cycle within a cycle :)

A
Alexey Gudyrin, 2020-02-21
@PlHePxJaS

I think so to output a component in a cycle :) I myself am an initial junior

and so the component is one 1 "plan", "result", "deviation" as many times as you like (but if the data is different then otherwise == the database is used in any case)
And how to make the necessary loop for my task in the Vue template?

<tr>
  <td v-for="n in 30">
//30 раз цикл запускать зачем можно по другому (я junior  <td v-for="n in 4"> )
</td>
</tr>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question