vue app全局变量
时间: 2023-10-29 17:57:49 浏览: 95
在Vue中,可以通过在`.env`文件中设置全局变量,然后在项目中使用`process.env`对象来获取这些变量的值。比如,在`.env`文件中设置了`VUE_APP_BASE_URL = 'https://www.baidu.com'`,那么在Vue项目中可以通过`process.env.VUE_APP_BASE_URL`来获取该全局变量的值。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [vue全局参数(env/全局变量)](https://blog.csdn.net/m0_68177019/article/details/128288381)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
- *2* *3* [vue如何定义:全局变量、全局方法](https://blog.csdn.net/qq_52421092/article/details/129533711)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文