I need to insert a compiled element in DOM
, however it will be inserted in a random place, not in a pre-defined place like this documentation ...
var res = Vue.compile('<div><span>{{ msg }}</span></div>')
new Vue({
data: {
msg: 'hello'
},
render: res.render,
staticRenderFns: res.staticRenderFns
})
All approaches with v-for
, v-if/show
will not serve me because they also require pre-defined elements.
I tried something like this ...
document.getElementById('elPai').insertAdjacentHTML('beforeend', Vue.compile('<div><span>{{ msg }}</span></div>'));
It returns an object containing render
and staticRenderFns
, but I do not find the result compiled in those objects, it seems to be that it is written to a promisse
, which is triggered when element is pre-defined in the DOM.
Finally, how can you insert elements compiled into the DOM with vue 2
?