Skip to content

Commit

Permalink
fix: build 报错,不能在template里面写 import.meta.env
Browse files Browse the repository at this point in the history
  • Loading branch information
feige996 committed Mar 30, 2024
1 parent 637f0f6 commit 936fabc
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions src/pages/demo/base/env.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,14 @@
当前环境 import.meta.env.DEV:
<text class="text-red-500 ml-4">{{ isDev }}</text>
</view>
<!-- <view class="mt-4 ml-4">
当前环境 import.meta.env.: {{ JSON.stringify(env, null, 2) }} (通过 import.meta.env 获取)
</view> -->
<view class="mt-4 ml-4">
当前环境所使用的环境文件 import.meta.env.VITE_ENV_FILE:
<text class="text-red-500 ml-4">{{ env.VITE_ENV_FILE }}</text>
当前环境所使用的环境文件
<text class="text-red-500 ml-4">{{ VITE_ENV_FILE }}</text>
</view>
<view class="text-red-500 mt-8 ml-4">环境变量的使用与 --mode 参数配合使用</view>
</template>

<script lang="ts" setup>
const isDev = import.meta.env.DEV
const { env } = import.meta
const { VITE_ENV_FILE } = import.meta.env
</script>

<style lang="scss" scoped>
//
</style>

0 comments on commit 936fabc

Please sign in to comment.