Write the Code. Change the World.

12月 08

项目中,配置文件的作用是想当美丽的。这样使代码看起来好看,用起来还方便。不至于因为某个条件或场景还跑到逻辑里去修改。vue cli 里边就可以自己定义 .env.production .env.development .env

https://cli.vuejs.org/zh/guide/mode-and-env.html

有下边的概念:

  • 通过 process.env.xxx 来取。
  • 对象命名以 VUE_APP_ 开头。 如 VUE_APP_API
  • .env.production 和 .env.development 会覆盖 .env 中定义的。

如果不生效,配置不生效,可能是定义对象的时候没以 VUE_APP_ 开头

这里列举几个定义:

# just a flag
ENV = 'production'

# base api
VUE_APP_BASE_API = 'http://117.24.6.252:8002'

# mode
VUE_APP_MODE = 'history'

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注