ARTICLE DETAIL

资讯详情

深耕郑州网站建设与运营推广的一线实战洞察。

Uniapp配置方案:根据当前运行环境自动配置后台域名

Uniapp配置方案:根据当前运行环境自动配置后台域名 // 开发环境配置 const devConfig { baseUrl: http://192.168.0.109:48080, // 开发环境域名 }; // 生产环境配置 const prodConfig { baseUrl: https://XXXXXX.com/api, // 生产环境域名 }; // 通过process.env.NODE_ENV自动识别环境 const isProduction process.env.NODE_ENV production; // 导出最终配置 const config isProduction ? prodConfig : devConfig; console.log(当前配置环境, isProduction ? 生产环境 : 开发环境, config); export default config;
返回列表