2

here's one of my computed methods:

            filtered() {
                return this.groups.map(group => {
                    return group.replace(this.search, '<span class="has-background-primary">' + this.search + '</span>');
                })
            }

This is supposed to highlight text in a searchbox, but the < is escaped to &lt;. What should i do to suppress escaping or how can I do it better?

Zbyszek Kisły
  • 2,110
  • 4
  • 26
  • 48

1 Answers1

6

You're on the right track. The only thing missing is a v-html at the place where you render your result/list.

<div v-for="item in items" v-html="item">
  <!-- if the item now contains raw html it will not be escaped -->
</div>

I've created a small fiddle for demonstration: http://jsfiddle.net/6bto2nkv/

Jns
  • 3,189
  • 1
  • 18
  • 23