0

I have some data that includes html tags in the state of vuex, but I want the html tags can be parsed as normal html tags, not to escape them. How can I achieve this task. For example,

export default {
  state: {
    someHtml: '<a href="">This is a a tag.</a>'
  }
}

this.$store.state.someHtml can be displayed as a html link.

soarinblue
  • 1,517
  • 3
  • 21
  • 30
  • Doesn't that defeat the purpose of using Vue? You're supposed to store data, not HTML strings. You should leverage the virtual DOM to construct elements instead. – Terry May 04 '17 at 15:31

1 Answers1

3

If you want to display unescapted HTML using Vue, use the v-html directive like so :

<div v-html="someHtml"></div>
Drown
  • 5,852
  • 1
  • 30
  • 49