Skip to content

adding mitt to vue global properties #818

Answered by RobertBoes
MellianStudios asked this question in Help
Discussion options

You must be logged in to vote

The following should work

require('./bootstrap');

import { createApp, h } from 'vue';
import { createInertiaApp } from '@inertiajs/inertia-vue3';
import { InertiaProgress } from '@inertiajs/progress';
import mitt from 'mitt';

const emitter = mitt();

createInertiaApp({
    resolve: name => import(`./Pages/${name}`),
    setup({ el, app: inertiaApp, props, plugin }) {
        const app = createApp({ render: () => h(inertiaApp, props) })
            .mixin({ methods: { route: window.route } })
            .use(plugin)

        app.config.globalProperties.emitter = emitter
        app.mount(el)
    },
})

InertiaProgress.init();

So, createApp() returns the Vue instance, save that to a vari…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@MellianStudios
Comment options

Answer selected by MellianStudios
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants