Raw or render HTML in Vue

Many times we have HTML content in a property or function that we want to render directly in the template; if we do it the usual way with braces {{}} it won't get the desired result, we have to use the v-html directive instead and tell it the property or function.

    <!-- **RAW HTML -->
    <p>
      {{ rawhtml }}
    </p>
    <p v-html="rawhtml"></p>
    <!-- **RAW HTML FIN-->

And in the JavaScript

rawhtml: "<span style='color:red'>Hola texto rojo</span>",

You can check the repo for more information.

I agree to receive announcements of interest about this Blog.

Many times we have HTML content in a property or function that we want to render directly in the template; do it with this directive.

- Andrés Cruz

En español