Kaynağa Gözat

fix(env): 环境变量不生效bug

Burt 2 yıl önce
ebeveyn
işleme
7e5e54678f
2 değiştirilmiş dosya ile 2 ekleme ve 0 silme
  1. 1 0
      src/utils/http.ts
  2. 1 0
      vite.config.ts

+ 1 - 0
src/utils/http.ts

@@ -11,6 +11,7 @@ type Data<T> = {
 
 // 请求基地址
 const baseURL = import.meta.env.VITE_SERVER_BASEURL
+console.log(import.meta.env)
 
 // 拦截器配置
 const httpInterceptor = {

+ 1 - 0
vite.config.ts

@@ -46,6 +46,7 @@ export default ({ command, mode }) => {
   console.log(env)
   console.log(process.env.UNI_PLATFORM) // 得到 mp-weixin, h5 等
   return defineConfig({
+    envDir: './env',
     plugins: [
       UniPages({ exclude: ['**/components/**/**.*'] }),
       UniPlatform(),