Vue always renders the last registered component, and only it. Even if I don't use it at all.
//main.ts
import Vue from 'vue';
Vue.component('component-one', require('./components/ComponentOne.vue'));
Vue.component('component-two', require('./components/ComponentTwo.vue'));
const app = new Vue({
el: '#app1',
vuetify,
})
//ComponentOne
<template>
<h2>Component One</h2>
</template>
<script lang="ts">
import Vue from 'vue'
export default class ComponentOne extends Vue{
}
</script>
//ComponentTwo
<template>
<h2>Component Two</h2>
</template>
<script lang="ts">
import Vue from 'vue';
export default class ComponentTwo extends Vue{
}
</script>
<body>
<div id="app1">
<!-- Whatever I put in here, it won't matter -->
<!-- I will always get only the content of the last registered component -->
<h2>Title</h2>
<component-one></component-one>
<component-two></component-two>
</div>
<script src="/js/app.js"></script>
</body>
What I get is the contents of ComponentTwo rendered on the page. Page screenshot
If I remove the lines that register my components, I'm able to use component libraries like Vuetify inside the div tag, but not if I don't. I expected to be able to use my components and any others any way I wanted inside the div tag.
Edit: Thank you guys for the answers. Is there a way to use these components inside the HTML element as I would in a template? Like so:
<!-- This could be a index.html or, in my case, a Laravel Blade view
<body>
<div id="app1">
<component-one></component-one>
<component-two></component-two>
</div>
<script src="/js/app.js"></script>
</body>
Vuetify components works fine this way if I don't register any custom component.