Skip to content

Instantly share code, notes, and snippets.

@cn-2k
Last active June 30, 2022 20:25
Show Gist options
  • Select an option

  • Save cn-2k/e7478c1b83e1e92d0937fc48675228c5 to your computer and use it in GitHub Desktop.

Select an option

Save cn-2k/e7478c1b83e1e92d0937fc48675228c5 to your computer and use it in GitHub Desktop.

Revisions

  1. cn-2k revised this gist Jun 30, 2022. 1 changed file with 3 additions and 8 deletions.
    11 changes: 3 additions & 8 deletions checkSlot.vue
    Original file line number Diff line number Diff line change
    @@ -1,22 +1,17 @@
    <template>
    <div>
    <nav
    v-if="content"
    v-if="slots.myNamedSlot"
    >
    <slot name="myNamedSlot" />
    </nav>
    </div>
    </template>

    <script setup lang="ts">
    import { useSlots, ref } from 'vue'
    <script setup>
    import { useSlots } from 'vue'
    const content = ref(false)
    const slots = useSlots()
    if (slots.myNamedSlot) {
    content.value = true
    }
    </script>

    <style>
  2. cn-2k revised this gist Jun 30, 2022. 1 changed file with 7 additions and 3 deletions.
    10 changes: 7 additions & 3 deletions checkSlot.vue
    Original file line number Diff line number Diff line change
    @@ -1,10 +1,14 @@
    <template>
    <div v-if="content">
    <slot name="myNamedSlot" />
    <div>
    <nav
    v-if="content"
    >
    <slot name="myNamedSlot" />
    </nav>
    </div>
    </template>

    <script setup>
    <script setup lang="ts">
    import { useSlots, ref } from 'vue'
    const content = ref(false)
  3. cn-2k revised this gist Jun 30, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion checkSlot.vue
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,7 @@
    </template>

    <script setup>
    import { useSlots, ref, computed } from 'vue'
    import { useSlots, ref } from 'vue'
    const content = ref(false)
    const slots = useSlots()
  4. cn-2k revised this gist Jun 30, 2022. 1 changed file with 3 additions and 7 deletions.
    10 changes: 3 additions & 7 deletions checkSlot.vue
    Original file line number Diff line number Diff line change
    @@ -1,10 +1,6 @@
    <template>
    <div>
    <nav
    v-if="content"
    >
    <slot name="contentEnd" />
    </nav>
    <div v-if="content">
    <slot name="myNamedSlot" />
    </div>
    </template>

    @@ -14,7 +10,7 @@ import { useSlots, ref, computed } from 'vue'
    const content = ref(false)
    const slots = useSlots()
    if (slots.contentEnd) {
    if (slots.myNamedSlot) {
    content.value = true
    }
    </script>
  5. cn-2k created this gist Jun 30, 2022.
    23 changes: 23 additions & 0 deletions checkSlot.vue
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    <template>
    <div>
    <nav
    v-if="content"
    >
    <slot name="contentEnd" />
    </nav>
    </div>
    </template>

    <script setup>
    import { useSlots, ref, computed } from 'vue'
    const content = ref(false)
    const slots = useSlots()
    if (slots.contentEnd) {
    content.value = true
    }
    </script>

    <style>
    </style>