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/action-this/main.svelte

20 lines
277 B

<script>
export let x = 0;
function foo(node) {
const handler = () => {
x += 1;
};
node.addEventListener('click', handler);
handler();
return {
destroy() {
node.removeEventListener('click', handler);
}
};
}
</script>
<button use:foo>{x}</button>