What is the Vue 3 equivalent of Vue 2's __vue__?

Viewed 1000

I see there's __vueParentComponent but I have to now say __vueParentComponent.props.x instead of __vue__.x. Also I can't see how I can access my custom variables (against the component instance) created in the beforeCreate method.

1 Answers

It looks like the following will give you access to everything you need:

__vueParentComponent.ctx

Update: This isn't available in production, however you can use the solution here. You basically create a global mixin (which will be applied to every component). Then in the mounted event you store the instance against the element. For example:

const app = Vue.createApp({ });

app.mixin({
    mounted() {
        this.$el.__vueComponent = this; // Or __vue__ for backwards compatibility.
    }
});
Related