Closed
Description
Following the official documentation, I have created the following components for my project.
{#if $$slots.labelText}
<!-- svelte-ignore a11y-label-has-associated-control -->
<label>
<slot name="labelText" />
<slot />
</label>
{:else}
<slot />
{/if}
This component will compile and run successfully.
However, when I used [email protected]
, I got a no-undef error.
./LabelInputArea.svelte
1:6 error '$$slots' is not defined no-undef
To developers who have encountered similar problems:
The $$slots
variable can be used within the script element.
So, I avoided this error by rewriting the following code.
<script lang="ts">
const slots = $$slots;
</script>
{#if slots.labelText}
<!-- svelte-ignore a11y-label-has-associated-control -->
<label>
<slot name="labelText" />
<slot />
</label>
{:else}
<slot />
{/if}
Metadata
Metadata
Assignees
Labels
No labels