Dynamic class name

NeverBe picture NeverBe · Oct 31, 2016 · Viewed 49.5k times · Source

How to generate dynamic class name?

  li v-for='obj in objs'
    | {{ obj.id }} {{ obj.title }}
    div id="obj-{{ obj.id }} " style="float:right; color:red;"

This sample doesn't work! I need this class name to update the div later!!!

Answer

NeverBe picture NeverBe · Oct 31, 2016

This helped me.

    div :class="['obj-' + obj.id]" style="float:right; color:red;"