D
D
Dmitry2020-10-14 13:11:53
Vue.js
Dmitry, 2020-10-14 13:11:53

How to access global. Vue 3 variables?

Hello.
I'm slowly picking vue 3 and even fell into a stupor with the new composition API. How can I access for example $router, $store or other variables? They write on the Internet that the second setup parameter should have a root property, but I don’t have it and the documentation states that there are only 3 keys in this parameter (attrs, emit, slots)
There is an option through getCurrentInstance or import the instance from the plugin, but this kind of crutch

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry, 2020-10-14
@By_Engine

Found the answer in the documentation
https://composition-api.vuejs.org/#plugin-development

A
Alexey Yarkov, 2020-10-14
@yarkov Vue.js

That's right. The context parameter must be the root object.
https://stackoverflow.com/a/58579885/7436149
PS I did not pick version 3 myself)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question