Reputation: 436
I have a question about slots. I want to add props / attrs to a default slot like this:
// Component.vue
<template>
<div>Component conten</div>
<slot :required="required" />
</template>
<script lang="ts" setup>
defineProps({
required: {
type: Boolean,
default: false
}
});
</script>
Without having to do this:
// Parent.vue
<template>
<Component required v-slot="{ required }">
<input :required="required" />
</Component>
</template>
So the question is, is there a way to do this without passing props back and forth between component and slot?
I hope i made myself clear. If not, let me know!
Thanks in advance!
Upvotes: 1
Views: 1906