1

I currently have an issue regarding vueJS.

I have a server side application which renders my html and sends it back in a string.

I want to insert this html into my page to display it.

I have it set up like this currently:

Template:

<div class="section" v-model="html">
   {{ html.body }}
</div>

This outputs the html as a string opposed to rendering it to the page.

Any idea on how to solve this ?

Thanks.

1 Answer 1

7

You can use the official v-html directive:

<div v-html="rawHtml"></div>

See the documentation for more information.

Sign up to request clarification or add additional context in comments.

2 Comments

Ah, thanks, one more question tho : how would i get my variable ``` {{ html.body }} ``` inside the v-html directive ? i cannot bind it with v-bind as the example on their page explains.
HTML is not allowed between curly brackets. Have you tried using <div v-html="html.body">? I guess html.body is part of the data configuration?

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.