[Vuejs]-Apply :style on v-for loop only once โ€“ vue.js

6๐Ÿ‘

โœ…

I would do something like this.

replace

    this.sessionColor = sessClr;
    this.exitColor = exitClr;
    this.bounceColor = bounceClr;
    this.timeColor = timeClr;,

with

    this.json[i].sessionColor = sessClr;
    this.json[i].exitColor = exitClr;
    this.json[i].bounceColor = bounceClr;
    this.json[i].timeColor = timeClr;

and refer in the html for each entry in json like below:

<td :style="{ 'background-color': page.sessionColor }">

check this fiddle

Hope it helps.

๐Ÿ‘คPradeepb

Leave a comment