ekjcfn3902039
ekjcfn3902039

Reputation: 1839

Vue issue rendering v-html inside of a table

I am trying to inject vue tags dynamically using v-html. However, it does not render as expected. I have attached a link to a jsFiddle example, where I try to add a v-icon via v-html. Instead of the tag being correctly injected, it strips the tags away and only renders the content inbetween.

Example:

The following code works fine, but it is not dynamic. What If I want other html tag(s) beside v-icon?

<table>
 <tr>
  <td><v-icon>mdi-car-side</v-icon></td>

The following code does not work, but is dynamic. It just places the icon name on the screen, and strips away the tags.

<table>
 <tr>
  <td v-html="dynamicData"></td>

https://jsfiddle.net/cgbwe31t/1/

I have read the blurb here https://v2.vuejs.org/v2/guide/syntax.html#Raw-HTML about 'Note that you cannot use v-html to compose template partials, because Vue is not a string-based templating engine', but I'm not sure that applies in this case.

Upvotes: 3

Views: 774

Answers (1)

ekjcfn3902039
ekjcfn3902039

Reputation: 1839

In case anyone was wondering, the best solution is to use v-slot to insert any html you want.

Upvotes: 2

Related Questions