3

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 ?

1 Answer 1

7

Try to use v-html directive :

 <div class="form-control" 
      type="text" id="view-container-wiki" 
      readonly 
      v-html="wiki.description">
 </div>
Sign up to request clarification or add additional context in comments.

3 Comments

@NewProgrammer I suggest you to parse it before rendering to avoid script injection. Like remove tags <script>
Thank you for the suggestion. I will look it
No problem, it seems there is no "native" function to do that. Maybe this will help stackoverflow.com/a/45262458/13604954

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.