mirror of
https://github.com/sveltejs/svelte.git
synced 2024-12-01 17:30:59 +01:00
Docs: document rest in array/object destructuring in each blocks (#2676)
This commit is contained in:
parent
fee4d351e1
commit
a7dd227336
@ -188,12 +188,20 @@ If a *key* expression is provided — which must uniquely identify each list ite
|
||||
|
||||
---
|
||||
|
||||
You can freely use destructuring patterns in each blocks.
|
||||
You can freely use destructuring and rest patterns in each blocks.
|
||||
|
||||
```html
|
||||
{#each items as { id, name, qty }, i (id)}
|
||||
<li>{i + 1}: {name} x {qty}</li>
|
||||
{/each}
|
||||
|
||||
{#each objects as { id, ...rest }}
|
||||
<li><span>{id}</span><MyComponent {...rest}/></li>
|
||||
{/each}
|
||||
|
||||
{#each items as [id, ...rest]}
|
||||
<li><span>{id}</span><MyComponent values={rest}/></li>
|
||||
{/each}
|
||||
```
|
||||
|
||||
---
|
||||
|
Loading…
Reference in New Issue
Block a user