Svelte – Reactive statements

0 min read


Hay guyss.. welcome back again.. lanjut lagi ke Reactive statement yaaa… untuk codenya kita mulai dengan seperti ini ..

<script>
	let count = 0;

	$: if (count >= 10) {
		alert(`count is dangerously high!`);
		count = 9;
	}

	function handleClick() {
		count += 1;
	}
</script>

<button on:click={handleClick}>
	Clicked {count} {count === 1 ? 'time' : 'times'}
</button>

dan begitulah hasilnyaa…

Source Code … oke see you on next post ..

Bima Sena

Leave a Reply

Your email address will not be published. Required fields are marked *