Home » vue » including html tag in state of vuex [duplicate]

including html tag in state of vuex [duplicate]

Posted by: admin November 26, 2021 Leave a comment

Questions:

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.

Answers:

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

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