You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
svelte/test/js/samples/event-handler-dynamic/input.svelte

23 lines
383 B

<script>
let clickHandler;
let number = 0;
function updateHandler1(){
clickHandler = () => number = 1;
}
function updateHandler2(){
clickHandler = () => number = 2;
}
</script>
<p>
<button on:click={updateHandler1}>set handler 1</button>
<button on:click={updateHandler2}>set handler 2</button>
</p>
<p>{ number }</p>
<button on:click={clickHandler}>click</button>