Ability to get the current component's name #12866
Unanswered
jasonvarga
asked this question in
Help/Questions
Replies: 1 comment 1 reply
-
use |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
We have a use case where we need to get the name of the current component. Typically within a mixin.
In Vue 2 we could do
this.$options.name
and it would return something likemy-component
.In Vue 3 there doesn't seem to be a way to do that. Is there?
Some more detailed context...
We have a system where third party developers can inject logic into other components. Here's some pseudocode:
Within our components we'd have something like:
Obviously there's more to it, and all of that is encapsulated within a mixin.
These components are all globally registered, so the names have already been defined.
It feels awkward to have to add a new property to every component just to be able to get the name.
It doesn't really matter if the name is
example-component-one
orExampleComponentOne
. As long as there's a consistent way to get it. I see things like__file
and__name
sometimes but they disappear when compiling for production.Any help would be appreciated! 🙏
Beta Was this translation helpful? Give feedback.
All reactions