Search This Blog

2017/08/05

vue.js: templateのclassを変数をつける

loopでarrayを出力する際、vueのclassをデータより変わりたい場合がある。
下記のようにarrayのデータをclassにつける。(':' + つけたいattr名) = "設定したい値"

array = [[value => value1],[value => value2]]

<Template>
<div v-for:"data in array">
<a href="" :class="'link' + data.value">
</div>
</Template>

実際出力の内容:
<div>
<a href="" class="link value1">
</div>
<div>
<a href="" class="link value2">
</div>
...

そのた:<img :src="データ値">

No comments :

Post a Comment