Search code examples
vue.jsslim-lang

Dynamic class name


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!!!


Solution

  • This helped me.

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