Banou26 Banou26 - 8 days ago 6
Javascript Question

How to append new components after init of the Vue [VueJS]

How to append a new element on the DOM and make that element be used by VueJS ?

For example in this https://jsfiddle.net/a0hnps42/1/ the element

<lel>after</lel>
is not transformed into
<div class='lel'>lele</div>
as
<lel>before</lel>
did.

Answer

You could use slots to with some directive to dynamically add new components:

<ul>
  <slot name="item"
    v-for="item in items"
    :text="item.text">
    <!-- fallback content here -->
  </slot>
</ul>

https://github.com/vuejs/vue/releases/tag/v2.1.0