Complete the code to import a child component in Svelte.
<script> import [1] from './Child.svelte'; </script>
In Svelte, you import components by their exact exported name. Here, the child component is named Child.
Complete the code to use the imported child component inside the parent component's markup.
<script> import Child from './Child.svelte'; </script> <main> <[1] /> </main>
In Svelte, component tags use the imported component's exact name with PascalCase.
Fix the error in passing a prop named 'title' to the child component.
<script> import Child from './Child.svelte'; </script> <Child [1]="Welcome" />
Props in Svelte are passed using the exact prop name defined in the child component, here title.
Fill both blanks to create a slot in the child component and use it in the parent component.
<!-- Child.svelte --> <div> [1] </div> <!-- Parent.svelte --> <script> import Child from './Child.svelte'; </script> <Child> [2] </Child>
The child component uses <slot /> to mark where passed content goes. The parent places content inside the child tags.
Fill all three blanks to pass a prop and use a named slot in the child component.
<!-- Child.svelte --> <script> export let [1]; </script> <h2>{ [2] }</h2> <div> <slot name="footer" /> </div> <!-- Parent.svelte --> <script> import Child from './Child.svelte'; </script> <Child [3]="Hello"> <p slot="footer">This is the footer content.</p> </Child>
The prop title is declared and used in the child. The parent passes title="Hello". The named slot footer is used for extra content.