How does vue create global variables

how to create global variables in vue.
refresh the page because of different templates.
so creating a new js and defining something in main that cannot be used will be initialized.
how to create a true global variable?

Aug.16,2021

directly hanging variables on window is true global variable

.
window.msg = 'asd'

of course, vue has many ways to realize data sharing vuex , bus and so on, which is the stupidest of all.


you can use

in main.js.
Vue.mixin({
    data(){
        name:""
    }
})

setup in other groups can be obtained through this.name.


https://www.jianshu.com/p/754.

Menu