Kunj
Kunj

Reputation: 2018

Style elements in Vue.js

I am trying to add style on elements from json in a Vue js:

<div v-for="(item, index) in json._items" class="help-inner-callout" v-html="item.text" style="top:item.top; left: item.left;"></div>

In my try loop is working and elements are filling with text by v-html="item.text" but style not applied. Can anyone have a look please, I just started learning Vue js..

Upvotes: 0

Views: 134

Answers (1)

apple apple
apple apple

Reputation: 10591

you need to bind it (v-bind:style or :style) since you use item

:style="{top:item.top, left: item.left}"

Upvotes: 2

Related Questions