vue-element-admin environment variables

vue-element-admin After 4.0 based on  vue-clito build, so all are based on an environment variable configuration vue-clito implement and control.

Official Documents

.env                # 在所有的环境中被载入
.env.[mode]         # 只在指定的模式中被载入

An environment file contains only environment variables "key = value" pairs:

FOO=bar
VUE_APP_SECRET=secret

note! ! !

Environment variables must be VUE_APP_to begin with. Such VUE_APP_APIas: ,VUE_APP_TITLE

You can get the code by:

console.log(process.env.VUE_APP_xxxx) 

In addition to  VUE_APP_* outside variables in your application code always available there are two special variables:

  • NODE_ENV - will be the "development", "production" or "test" one. Value depends on the operating mode of the application.
  • BASE_URL - and will be  vue.config.js in the  publicPath options match, that your application will be deployed to the base path.

# Build-related

Except for some written in the .envoutside environment variable, and some build and deploy relevant variables are required in the vue.config.jsconfiguration.

You can process.env.NODE_ENVbe performed to determine the environment, to set different parameters.

Specific code can learn vue.config.js

http://www.kemaisii.cn
http://www.eternelle.cn
http://www.yajuxuan.cn
http://www.nodonkg.cn
http://www.yurunyipinn.cn
http://www.niudangjiaa.cn
http://www.feikeshoubiaoo.cn
http://www.yumengse.cn
http://www.parniss.cn
http://www.sensefadd.cn
http://www.youmaqi.cn
http://www.yinghengg.cn
http://www.xizuann.cn
http://www.vapsint.cn
http://www.moshii.cn
http://www.shamandaweiyu.cn
http://www.taiguangyinlou.cn

 

Guess you like

Origin www.cnblogs.com/zjhcap/p/11484936.html