vue.jsspecial-characters

Vue template - render HTML special character codes


How can I fully render HTML special characters codes in my Vue template?

For instance I have this JSON data:

[{"id":"post91","slug":null,"title":"Breakfast & Tea"}]

How can I convert Breakfast & Tea to Breakfast & Tea?

My Vue template:

<h3 class="heading">{{ item.title }}</h3>

Any ideas?


Solution

  • The best option is using v-html actually:

    <h3 class="heading" v-html="item.title"></h3>
    

    No need of any other libs.