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.html

20 lines
278 B

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