1、配置环境变量,注意 要以“VITE“开头
(1)在.env.development中配置环境变量
VITE_APP_ENV= development
2、在vue文件中使用
<script setup lang="ts"> console.log('环境:', import.meta.env) </script>
打印得结果:
{ "BASE_URL": "/", "DEV": true, "MODE": "development", "PROD": false, "SSR": false, "VITE_APP_ENV": "development", "VITE_USER_NODE_ENV": "development" }
3、在vite.config.ts中使用
export default ({command,mode}) => { console.log(" 标签:development,console,log,配置,VITE,env,环境变量,vite,mode From: https://www.cnblogs.com/hwy6/p/18543453