当前位置:网站首页>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
边栏推荐
- 17 `bs object Node name h3 Parent ` parents get parent node ancestor node
- Extensible database (Part 2)
- Tardigrade: Trino's solution to ETL scenarios
- Object class, and__ new__,__ init__,__ setattr__,__ dict__
- 密码加密md5和加盐处理
- Is Guotai Junan Securities reliable? Is it safe to open a securities account?
- MySQL错误
- 数组的方法
- Why is the service implementation class always red
- 猴子都会用的圆形滑动自动吸附UI工具
猜你喜欢

以自动化赋能转型,飞鹤乳业加速迈向数字化!

STM32 peripheral SDIO and SD card configuration

R1 Quick Open Pressure Vessel Operation Special Operation Certificate Examination Library and Answers in 2022

導入Excel文件,解决跳過空白單元格不讀取,並且下標前移的問題,以及RETURN_BLANK_AS_NULL報紅

用于 C# 的 SQL 基本语法总结

资源管理、高可用与自动化(下)

Hot! Yolov6's fast and accurate target detection framework is open source (with source code download)

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

Summary of SQL basic syntax for C #

Resource management, high availability and automation (Part 2)
随机推荐
以自动化赋能转型,飞鹤乳业加速迈向数字化!
Custom controls under WPF and adaption of controls in Grid
Circular sliding auto adsorption UI tool that monkeys can use
Analysis of slow logs in MySQL and tidb of database Series
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
Go speed
用于 C# 的 SQL 基本语法总结
17 `bs object Node name h3 Parent ` parents get parent node ancestor node
可扩展存储系统(上)
Extensible database (I)
Li Kou daily question - day 29 -1491 Average wage after removing minimum wage and maximum wage
A pit filling trip based on LNMP to build a personal website
Tardigrade: Trino's solution to ETL scenarios
Automatic backup of MySQL database
Hot! Yolov6's fast and accurate target detection framework is open source (with source code download)
nn. Parameter and torch nn. Init series of functions to initialize model parameters
MySQL error
MySQL configuration of database Series F5 load balancing
Tardigrade:Trino 解决 ETL 场景的方案
Redis cluster setup [simple]