Replace com Vuejs

Asked

Viewed 349 times

1

Next, I’m making a Filter to search some words passed by parameters and check if it exists in the text. The words that are equal I will have to highlight them with a bold and a background. Only, when I tag Strong, vuejs does not render properly.

I have something similar to that:

<p>{{texto|detarcarPalavra("palavra")}}<p>

in the output I wanted, if the word is found, to highlight only this word.

  • I think in this case it might be better to use the v-html. You can show an example of text and how you want HTML to look?

  • The code looks like this: Foundation <Strong>ELE</Strong> of Social Security

  • But it should stay like this: Foundation HIM welfare

  • 1

    Yes, I know. HTML is not treated as HTML. You should use <p v-html="detarcarPalavra(texto, "palavra")"><p>

  • 1

    Vlw! It worked. Stupid question, but I had become bewildered.

1 answer

2


In this case it would be better to use the v-html. This tool can open safety holes in the application, so it should be used carefully.

But for the purpose you intend to do so you can do so:

<p v-html="detarcarPalavra(texto, "palavra")"><p>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.