Global data with VueJs 2

前端 未结 3 798
醉梦人生
醉梦人生 2020-11-27 17:10

Im relatively new with VueJS, and I\'ve got no clue about how to make some data globally available. I would like to save data like API endpoints, user data and some other da

3条回答
  •  独厮守ぢ
    2020-11-27 17:58

    I just use an environment.js file to store all of my endpoints as object properties.

    var urls = {};
    urls.getStudent = "api/getStudent/{id}";
    etc...
    

    Then I put reference to this environment.js file in the head of document on pages where I have VueJS code that needs access to those endpoints. Im sure there are many ways to do this.

提交回复
热议问题