3

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.

0

1 Answer 1

2

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

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

Comments

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.