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.

- Andrés Cruz

En español
Andrés Cruz

Develop with Laravel, Django, Flask, CodeIgniter, HTML5, CSS3, MySQL, JavaScript, Vue, Android, iOS, Flutter

Andrés Cruz In Udemy

I agree to receive announcements of interest about this Blog.