Skip to content

Instantly share code, notes, and snippets.

@Idered
Created March 7, 2022 12:45
Show Gist options
  • Save Idered/31be8ea5bf2f033ebb07c2a3ea2a8ba0 to your computer and use it in GitHub Desktop.
Save Idered/31be8ea5bf2f033ebb07c2a3ea2a8ba0 to your computer and use it in GitHub Desktop.

Revisions

  1. Idered created this gist Mar 7, 2022.
    15 changes: 15 additions & 0 deletions UseEnv.vue
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    <template>
    <slot :env="env" />
    </template>

    <script setup lang="ts">
    const env = computed(() =>
    Object.entries(import.meta.env).reduce(
    (acc, [key, value]) => ({
    ...acc,
    [key]: value,
    }),
    {} as ImportMetaEnv,
    ),
    )
    </script>