-
Notifications
You must be signed in to change notification settings - Fork 79
Open
Labels
- P2-to-be-discussedNeeds discussionNeeds discussion
Description
Astro Info
Astro v3.0.10
Node v20.5.1
System Linux (x64)
Package Manager npm
Output static
Adapter none
Integrations @astrojs/vue
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
I have tried to use variable values as slot names but it isn't working (see below).
NOTE: I've simplified my use case here for code example only - I do have a valid use case for sending HTML to slots from outside the Example component (tables with HTML content)
This is a simple Vue component using named slots based on values in the props.
<script lang="ts" setup>
export interface Props {
items: {
id: string;
}[];
}
defineProps<Props>();
</script>
<template>
<template v-for="item of items">
<div
v-if="$slots && $slots[item.id]"
>
<slot :name="item.id" />
</div>
</template>
</template>
This is an example of me using the above vue component within an astro file to try populate slots with a mapped value.
---
const items = [
{ id: "1"},
{ id: "2"},
{ id: "abc"}
];
---
<Example items={items}>
{items.map(({ id }) => <p slot={id}>{id}</p>)}
</Example>
Unfortunately I'm being hit with:

I have logged the id
and it it is defined... just not when used as the slot name
What's the expected result?
I'd expect astro to use the value to populate the named slot in the child component. with the output:
<div>
<p>1</p>
</div>
<div>
<p>2</p>
</div>
<div>
<p>abc</p>
</div>
Link to Minimal Reproducible Example
https://stackblitz.com/edit/github-vqaya3
Participation
- I am willing to submit a pull request for this issue.
Mouazstavros-k, HunorMarton and Mouaz
Metadata
Metadata
Assignees
Labels
- P2-to-be-discussedNeeds discussionNeeds discussion