I haven't found this feature anywhere in svelte 3.. I want it to be something like this..
App.svelte
<Error>
<p>Can't connect to the server!</p>
</Error>`
Error.svelte
<div>{props.children}</div>
I want App.svelte to show:
<div><p>Can't connect to the server!</p></div>
I only know how to do this with React's props.children.
You can use slot . It is a component provided by svelte. You can use it inside your component. Whatever is passed to component will be rendered in place of slot
Try this in your error.svelte
<div>
<slot />
</div>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.