Skip to main content

이벤트 전달은 DOM 이벤트에도 작동합니다.

<BigRedButton>에서 클릭에 대한 알림을 받고 싶다면, BigRedButton.svelte<button> 요소에서 click 이벤트를 전달하면 됩니다.

BigRedButton.svelte
<button on:click>
	Push
</button>

Next: Bindings

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<script>
	import BigRedButton from './BigRedButton.svelte';
	import horn from './horn.mp3';
 
	const audio = new Audio();
	audio.src = horn;
 
	function handleClick() {
		audio.load();
		audio.play();
	}
</script>
 
<BigRedButton on:click={handleClick} />
 
initialising