Skip to content

Make it work with setup sugar #4

@biroplane

Description

@biroplane

To make it work wit vue 3.4 and setup sugar syntax, i've updated the script as follow:

<script setup lang="ts">
import { computed, provide, ref, useSlots } from "vue";

const slots = useSlots();

const tabTitles = computed(
  () =>
    slots.default &&
    (slots!.default()[0].children as any)!.map((t: any) => t.props.title)
);

const selectedTiltle = ref(tabTitles.value[0]);

provide("selectedTitle", selectedTiltle);
</script>

i didn't test it with named slots or other use cases, but it works in my project
hope this heps.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions