浏览代码

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

Burt 2 年之前
父节点
当前提交
7e5e54678f
共有 2 个文件被更改,包括 2 次插入0 次删除
  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(),