EcStud
EcStud

Reputation: 61

Dynamic param in vue's template mustage tag

There are columns in my DB named like 'h_01', 'h_02' ... 'h_23'. In vue template I try to use this construction:

<td v-for="hour in hours">{{'item.h_'+hour}}</td>

But as the result I see only "item.h_1" in table cells, but not the real value from DB.

What I'm doing wrong?

Here is the FF screen:

enter image description here

Upvotes: 1

Views: 26

Answers (1)

Sajib Khan
Sajib Khan

Reputation: 24174

Change to

{{ item["h_" + String(hour).padStart(2, '0')] }}

Upvotes: 1

Related Questions