vue 发布创建配置文件config.js


vue 发布创建配置文件config.js

1.在vue public 目录下新建config文件夹,然后新建config.js
window.APIURL={
rootUrl:'http://10.xx.xx.xx:5199/'
}

1.2 public/index.html 加入对config.js的引用: <script src="/config/config.js"></script>

2. 在main.js 文件里添加:
axios.defaults.baseURL = process.env.NODE_ENV === 'development' ? 'http://localhost:55031/' : window.APIURL.rootUrl

Vue.prototype.$http = axios

3. 在vue ui里 build 完成后,会自动在disk 文件夹下生成disk/config/config.js,配置前端调用的api接口地址。


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM