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/runtime/samples/event-handler-dynamic-hash/main.svelte

23 lines
394 B

<script>
let clickHandler = {};
let number = 0;
function updateHandler1(){
clickHandler.f = () => number = 1;
}
function updateHandler2(){
clickHandler.f = () => 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.f}>click</button>