Is there a way for me to trigger events from my child components and have them reach the top-level App.vue
component even though I am using a RouterView
to render the child components in the App.vue
template?
<template>
<Navbar />
<component :is="$route.meta.layout || 'div'">
<RouterView @display-modal="handleDisplayModal" />
</component>
</template>
Vue is warning me about non-emits event listeners being passed to the component due to the use of RouterView
:
[Vue warn]: Extraneous non-emits event listeners (displayModal) were passed to component but could not be automatically inherited because component renders fragment or text root nodes. If the listener is intended to be a component custom event listener only, declare it using the "emits" option.
at <Home onDisplayModal=fn<handleDisplaymodal> onVnodeUnmounted=fn<onVnodeUnmounted> ref=Ref< undefined > >
at <RouterView onDisplayModal=fn<handleDisplaymodal> >
at <LayoutBoxed>
at <App>
Since RouterView
is not my component, I cannot declare the event with "emits." How can I resolve this warning without having to modify all the views rendered by router-view both now and in the future?
My versions:
vue: 3.2.47
vue-router: 4.1.6