1、在static文件夾新建一個config.js,打包後生成的相同名文件夾,更改裏面值就可以了
window.global_config = {
BASE_URL: 'http://deuv.ulocuuuual.cn',
// BASE_URL: 'http://192.168.199.178:700'
};
2、在index.html文件裏引入config.js
<script src="./static/config.js"></script>
3、封裝的axios裏的baseURL寫成global_config.BASE_URL
const service = axios.create({
baseURL: global_config.BASE_URL, // api 的 base_url
timeout: 20000 // 請求超時時間
})