Skip to content

Vue Composition API: Slots

Mike Lyttle edited this page May 9, 2023 · 1 revision

Class Component

    get hasSlot(): boolean {
        return this.$slots.default !== undefined;
    }

Composition API

import { computed, useSlots } from "vue";
const slots = useSlots();
const hasSlot = computed(() => slots.default !== undefined);

Documentation

Clone this wiki locally