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

22 lines
328 B

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