[Vuejs]-How to make the received data appear as HTML code?

1👍

You could use Vue v-html directive to insert Html in div.

Working example:

new Vue({
    el: '#app',
    data: {
        html: '<a href="foo">Some link </a>'
    }
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id="app">
<textarea v-model="html"></textarea>
<div v-html="html"></div>
</div>

3👍

We have to use v-html directive inorder to work. Take a look at the documentation Here, check the working snippet.

var app6 = new Vue({
  el: '#app-6',
  data: {
    message: '<a href="google.com">Hello Vue!</a>'
  }
})
.as-console-wrapper{
  display:none!important;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.12/vue.js"></script>
<div id="app-6">
  <p v-html="message"></p>
  <textarea v-model="message"></textarea>
</div>

Leave a comment