https://vuejs.org/guide/components/registration.html#global-registration
import Example from './components/Example'
const app = createApp({})
app.component('example', Example)
app.mount('#app')
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I used Vuejs 2 on my projects and in some views at the bottom of each one I put my Vuejs instance, and in app.js just register Vuejs globally and register Vuejs components.
Everything working fine but today I wanted to upgrade to Vuejs 3 but the problem is that when I register Vuejs 3 components I have to mount it to an HTML element and this makes problem with the instance in each view. app.js in Vue v2:
require('./bootstrap');
window.Vue = require('vue').default;
Vue.component('example', require('./components/Example.vue').default);
app.js in Vue v3:
require('./bootstrap');
window.Vue = require('vue');
import { createApp } from 'vue';
import example from './components/Example.vue';
createApp({
components: {
example
}
}).mount('#app');
The instance in view page also mounted to #app, I tried to make view instance to another element but still not working.
Please or to participate in this conversation.