How to access the window object in vue js?

前端 未结 2 569
夕颜
夕颜 2021-02-05 07:12

I have this vue js component:





        
2条回答
  •  孤街浪徒
    2021-02-05 07:57

    You should save your window variable in Vue.prototype

    main.js

    Vue.prototype.$authUser = window.authUser;
    

    After that, you can access your data as follows:

    Vue template

    Vue script

    let name = this.$authUser.name;
    

提交回复
热议问题