I'm having some trouble getting acces to global state in the setup function.
Originally I used to use $root, but I've also tried via provide/inject, but in both cases I haven't been able to access the values.
In main.ts, where the app is created:
import VueCompositionAPI from '@vue/composition-api'
Vue.use(VueCompositionAPI)
new Vue({
router,
vuetify,
data: {
clientId: null,
},
provide () {
return { userId: 42 }
},
render: h => h(App),
async created() {
this.$root.clientId = 43
},
}).$mount('#app')
Then later in some component that uses this composition-api:
I'm having some trouble getting acces to global state in the setup function. Originally I used to use $root, but I've also tried via provide/inject, but in both cases I haven't been able to access the values.
In main.ts, where the app is created:
Then later in some component that uses this composition-api:
Trying to access $root:
Trying to access inject/provide; method 1/2
Trying to access inject/provide; method 2/2: (this enables the use of the {{userId}} on the template, but still not in the setup).
I've also tried some variations of these, but so far have not been able to access any value in setup()