Post

RestProps

♧ RestProps

  • 설명
    Child에서 $$restprops로 Parent에 정의된 값을 사용할 수 있다.

▶ 예제

  • 파일: App.svelte
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<script>
	import Button from './Button.svelte';
</script>

<Button
	on:click|once={(event) => {
		alert(true);
	}}
	restprops1
	disabled
>
	Button Text
</Button>

  • 파일: Button.svelte
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<script>
</script>

<button
	on:click
	{...$$restProps}
>
	{#if $$restProps.restprops1}
		<div>
			restprops1
		</div>
	{/if}
	<slot {isLeftHovered}>Fallback</slot>
</button>

This post is licensed under CC BY 4.0 by the author.