Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to show formatted html string using vue.js

I have this problem, I created a html page to show some texts formatted using quill editor. I save every text created in a table using this format as example:

<p>Test<strong> format</strong></p>

To show the text in my front end, I'm using a v-for with vue.js, like this:

<div class="card" v-for="(wiki, index) in wikiList">
   <div class="mb-3">
       <div class="form-control" type="text" id="view-container-wiki" readonly>{{wiki.description}}</input>
   </div>
</div>

The problem is that my html is not formatting the text, its just showing it with tags:

enter image description here

How can I create a method to return the string formatted ? I tried using Jquery, but it didn't work.

Any suggestion ?

like image 905
NewProgrammer Avatar asked Dec 14 '25 10:12

NewProgrammer


1 Answers

Try to use v-html directive :

 <div class="form-control" 
      type="text" id="view-container-wiki" 
      readonly 
      v-html="wiki.description">
 </div>
like image 138
Nikola Pavicevic Avatar answered Dec 15 '25 22:12

Nikola Pavicevic



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!