In Vue 2, we were accustomed to importing Vue, and prior to mounting the application, use the global Vue instance to add the plugins, filters, components, router, and store. This was a good technique where we could add anything to the Vue instance without needing to attach anything to the mounted application directly. It worked like this:
import Vue from 'vue';
import Vuex from 'vuex';
import App from './App.vue';
Vue.use(Vuex);
const store = new Vuex.store({});
new Vue({
store,
render: (h) => h(App),
}).$mount('#app');
Now, in Vue 3, this is no longer possible. We need to attach every component, plugin, store, and router to the mounted instance directly:
import { createApp } from 'vue';
import { createStore } from 'vuex';
import App from './App.vue';
const store = createStore({});
createApp(App)
.use(store)
.mount('#app');
Using this method, we can create different...