Global variable access issue in vue-3 with composition api, while using setup with script tag? #6731
Unanswered
plabonislam
asked this question in
Help/Questions
Replies: 1 comment
-
Using the Composition API then you'll still be able to use these properties within the template, but you won't have access to the component instance within So you can just use application-level With an explicit setup function import { inject } from 'vue'
export default {
setup() {
const globalVariable = inject('globalVariable')
console.log(globalVariable)
}
} or with api options, inside a component in the application: export default {
inject: ['globalVariable']
} refs: https://vuejs.org/api/application.html#app-provide, https://github.com/vuejs/rfcs/blob/master/active-rfcs/0009-global-api-change.md |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
question: ### How can I access global variables while using composition API with setup in script tag ?
Should I use getCurrentInstance or another way?
Beta Was this translation helpful? Give feedback.
All reactions