Question
Given I am in component context, how do I get the component object? By component object I mean the object you get when you import Component from 'Component.vue'
.
Current progress
Here's one possibility I found.
const component = {
methods: {
getComponent: () => this,
displayItem () {
console.log('this.getComponent()', this.getComponent()) // undefined
console.log('this', this) // component instance
console.log('component', component) // what I need (component object)
},
},
}
export default component
The downside though is that it kills IDE support.
I also checked this
manually.
Ideal solution
The approximation to syntax I'd like to see: this.$component
.
What's the point?
- Instantiate components via
:is="component"
. - Perform instance of check.
this
. - Phitervm.$options._Ctor[0]
but i'm not sure what[0]
is here. - tsh