How to get globalProperties in normal js
What problem does this feature solve?
In vue2.x, I can use Vue.prototype
, in vue3.x, should I export the app
of main.js, and import app
in normal js? Or there's other way.
What does the proposed API look like?
none
app.config.globalProperties.$foo = 'hello'
usage
created(){
console.log(this.$foo)
}
If you want to use it outside the component, maybe you can bind the data to the window or use Vuex to solve it.
Please, next time consider using the forum, the Discord server or StackOverflow for questions first. But feel free to come back and open an issue if it turns out to be a bug 🙂