add docs for $$restProps

pull/4489/head
Tan Li Hau 6 years ago
parent 6fd37e10ba
commit 7a54cbba69

@ -113,6 +113,9 @@ An element or component can have multiple spread attributes, interspersed with r
<Widget {...$$props}/>
```
---
*`$$restProps`* references to props that are passed to a component which are not declared with `export`. It is useful for passing down attributes that are not expected as props.
### Text expressions

@ -0,0 +1,9 @@
<script>
import Input from './Input.svelte';
export let value = '';
$: ({ value, ...rest } = $$props);
</script>
<Input {value} name="email" aria-label="Email" />

@ -0,0 +1,7 @@
<script>
export let value = '';
$: ({ value, ...rest } = $$props);
</script>
<input bind:value {...rest} />

@ -0,0 +1,9 @@
<script>
import Input from './Input.svelte';
export let value = '';
$: ({ value, ...rest } = $$props);
</script>
<Input {value} name="email" aria-label="Email" />

@ -0,0 +1,5 @@
<script>
export let value = '';
</script>
<input bind:value {...$$restProps} />

@ -0,0 +1,9 @@
---
title: $$restProps
---
If you want to pass down props that are not defined with `export`, you can use `$$restProps`:
```html
<input {...$$restProps}/>
```
Loading…
Cancel
Save