当前位置:网站首页>uni-app 如何根据环境自动切换请求的地址
uni-app 如何根据环境自动切换请求的地址
2022-06-28 02:59:00 【Dark_programmer】
在vue中,可使用 process.env.NODE_ENV的值来判断当前环境是开发环境还是生产环境。在uni-app中也可使用该值进行区分环境。
使用 HBuilderX进行开发:
点击“运行”编译出来的代码是开发环境,点击“发行”编译出来的代码是生产环境
export default BASE_URL = process.env.NODE_ENV === 'development' ? '测试地址' : '正式地址'
然后把该变量用在合适的地方即可
或者在package.json 中配置
https://uniapp.dcloud.io/collocation/package
边栏推荐
- 荣耀v8 真机调试时不显示 Logcat 日志的解决办法
- 2022 safety officer-c certificate examination question bank simulated examination platform operation
- crond BAD FILE MODE /etc/cron. d
- 图片的懒加载和预加载
- View the SQL execution plan according to explain and optimize the SQL
- collections. Use of defaultdict()
- Learning - useful resources
- Analysis of slow logs in MySQL and tidb of database Series
- No  result  defined& nbsp…
- 【PaddleDetection】ModuleNotFoundError: No module named ‘paddle‘
猜你喜欢

Anaconda command usage

"Five layer" architecture of cloud applications and services

17 `bs对象.节点名h3.parent` parents 获取父节点 祖先节点

Importer un fichier Excel, résoudre le problème de sauter les cellules vides et de ne pas lire, et avancer l'indice, et retourner Blank As NULL Red

How does the open-ended Hall current sensor help the transformation of DC power distribution?

STM32外设SDIO和SD卡的配置

mysql获取当前时间是一年的第多少天

Paging query optimization in MySQL of database Series

service实现类里面为何一直报红

matlab习题 —— 矩阵的常规运算
随机推荐
失联修复:让“躲猫猫”无处可藏
Basic operation of stack (implemented in C language)
【PaddleDetection】ModuleNotFoundError: No module named ‘paddle‘
密码加密md5和加盐处理
解决跨域
What is the core problem to be solved in the East and West?
数组的方法
数据库乱码问题
2022 safety officer-c certificate examination question bank simulated examination platform operation
Li Kou daily question - day 29 -575 Divide candy
Resource management, high availability and automation (medium)
Custom controls under WPF and adaption of controls in Grid
大咖说·计算讲谈社|什么是东数西算要解决的核心问题?
Why is the service implementation class always red
如何给Eclips自动添加作者,时间等…
Ten years' experience of Software Engineer
17 `bs object Node name h3 Parent ` parents get parent node ancestor node
导入Excel文件,解决跳过空白单元格不读取,并且下标前移的问题,以及RETURN_BLANK_AS_NULL报红
Websocket (simple experience version)
猴子都会用的圆形滑动自动吸附UI工具