Skip to content

Commit

Permalink
chore(example): update glob example
Browse files Browse the repository at this point in the history
  • Loading branch information
wenqing committed Dec 20, 2023
1 parent e4ae9db commit 54f3126
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 0 deletions.
21 changes: 21 additions & 0 deletions example/src/components/GlobUsage/DemoCode.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<template>
<div class="">See console</div>
</template>

<script lang="ts" setup>
import { onMounted } from 'vue'
const iconsImport = import.meta.glob('@/icons/**.svg', {
import: 'default',
eager: true,
query: {
component: '', // import SVG as a vue component
// raw: '', // Or import SVG as a pure text
// url: '', // or import SVG as a url
},
})
onMounted(() => {
console.log(iconsImport)
})
</script>
37 changes: 37 additions & 0 deletions example/src/components/GlobUsage/index.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<template>
<div class="">
<FeatureSection>
<template #title> <code>with glob of vite</code> </template>

<template #sub-title>
<div>
Supports importing multiple modules from the file system via the
special
<code class="lang-js">import.meta.glob</code>
function:
</div>
</template>

<template #demo>
<DemoCode />
</template>

<template #code>
{{ DemoCodeRaw }}
</template>
</FeatureSection>
</div>
</template>

<script lang="ts" setup>
import FeatureSection from '@/components/FeatureSection.vue'
import DemoCode from './DemoCode.vue'
import DemoCodeRaw from './DemoCode.vue?raw'
</script>

<script lang="ts">
import { defineComponent } from 'vue'
export default defineComponent({
name: 'UrlQueryString',
})
</script>
2 changes: 2 additions & 0 deletions example/src/views/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<MaintenanceColors />
<MaintenanceSize />
<SkipsvgoQueryString />
<GlobUsage />
</div>
</div>
</div>
Expand All @@ -40,6 +41,7 @@ import RawQueryString from '@/components/RawQueryString/index.vue'
import SkipsvgoQueryString from '@/components/SkipsvgoQueryString/index.vue'
import MaintenanceColors from '@/components/MaintenanceColors/index.vue'
import MaintenanceSize from '@/components/MaintenanceSize/index.vue'
import GlobUsage from '@/components/GlobUsage/index.vue'
</script>

<script lang="ts">
Expand Down

0 comments on commit 54f3126

Please sign in to comment.