Replies: 3 comments
-
This is an annoying little thing that keeps cluttering the console during debugging. Hope someone could look into it soon. |
Beta Was this translation helpful? Give feedback.
-
The warning is there to help people find problems. In this case, it warns because it's applied to too many components (all existing pages) so it's normal for it to appear more than it should. Adding a modifier to remove a development warning would be problematic as |
Beta Was this translation helpful? Give feedback.
-
Chiming in to optimistically ask, has anybody found a solution to this warning message? It seems like there's only four options:
Unfortunately none of these solutions are ideal. It seems that either this warning should not trigger when attaching to router views, or there should be a way to suppress it. You have to admit it does feel pretty sloppy to publish a web app with warnings in the console. I do like the idea of the @posva wrote:
It doesn't seem too confusing if we document which one takes precedence. I would say As for people using it to silence warnings, I think at some point you have to give developers tools that they can make mistakes with. If a dev is reaching for a way to silence a warning, it means they've already been informed of it and made a decision. This situation with Besides, offering more control over fallthrough attributes would not be unwelcome. There's already a lot of magic happening behind the scenes, like changing fallthrough behaviour if a prop of the same name is being consumed. Mostly I'd just like to find a solution to this warning, but @jez9999's suggestion seems like a good one to me. |
Beta Was this translation helpful? Give feedback.
-
What problem does this feature solve?
Vue always tries to make a child element's root element auto-inherit an attribute or event listener if it's not explicitly defined in the child with props or emits. There should be a
.noinherit
modifier which prevents this behaviour, in case the parent doesn't want the child to inherit the attribute/listener and only wants it to apply if the child explicitly deals with it.In addition, if the child has multiple root-level nodes, this will prevent the "Extraneous non-emits event listeners" warning from appearing. This is particularly useful when applying an event listener to a
router-view
, which becomes one of many different rendered routes, some of which may emit a particular event and some of which may not. Without a.noinherit
, every single component with multiple root nodes that may be rendered by the router needs to be examined for every event listened to and either giveninheritAttrs:false
or explicitly defined as emitting that event, even if the component actually has no intention of emitting the event, in order to avoid the warning. For instance, in the followingApp.vue
template:... every child component that might get rendered by the
router-view
would have to explicitly not inherit attributes, or explicitly definedisplaymodal
anddisplaypopup
as emits, to avoid the warning. WhatApp.vue
really wants to say is "if the child emits this event, handle, but if not, do nothing, and don't give a spurious warning".What does the proposed API look like?
Beta Was this translation helpful? Give feedback.
All reactions