0๐
โ
I believe you do something like this: Inserting in DOM.
- Use a
$ref
instead of an ID - Create a new element and
$mount
it - Get the
$ref
of the parent and append the DOM element that way
const EquipmentInput = Vue.extend({
template: "<div>Hello World</div>"
});
const app = new Vue({
el: "#app",
components: {
EquipmentInput
},
methods: {
add() {
const instance = new EquipmentInput();
instance.$mount();
this.$refs.ediv.appendChild(instance.$el);
}
}
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id="app">
<div ref="ediv"></div>
<button @click="add">Click Me</button>
</div>
Source:stackexchange.com