vuejs configuration: using a global variable?

后端 未结 3 1682
有刺的猬
有刺的猬 2021-01-02 06:28

This seems dumb, but I have it setup like this:

in config/index.js:

module.exports = {
    API_LOCATION: \'http://localhost:8080/api/\'
         


        
3条回答
  •  清酒与你
    2021-01-02 06:54

    Simply set ip path(or localhost) in local storage when login successfull and get value from local storage where you need through out the project. here how you set value in localstrage.

    // Set value in IpAdress localstorage.setItem('IpAddress','192.168.100.100:8080');

    // Get value from IpAddress localstorage.getItem('IpAddress');

    in my case whole path looks like: localstorage.getItem('IpAddress')+/api/controller/method|

提交回复
热议问题