问题
I am trying to create some environment variables for my application but they are always undefined for some reason. I followed some guides and did the following
Created a file called .env
added the following into the file
VUE_APP_MY_ENV_VARIABLE = myValue
In my App.js
file added the following:
beforeMount(){
console.log(process.env.VUE_APP_MY_ENV_VARIABLE)
}
ran npm run serve but the variable always comes as undefined. I also ran npm run build and npm run serve multiple times but it ain't working for some reason.
来源:https://stackoverflow.com/questions/61370527/environment-variables-are-always-undefined-in-vuejs-application