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-custom-each-d.../main.html

37 lines
612 B

{#each items as [item0, item1]}
<button on:tap='set({ first: item0, second: item1 })'>
{item0}: {item1}
</button>
{/each}
<p>first: {first}</p>
<p>second: {second}</p>
<script>
export default {
data: () => ({
x: 0,
y: 0,
first: '',
second: '',
items: [ [0, 'foo'], [1, 'bar'], [2, 'baz'] ]
}),
events: {
tap ( node, callback ) {
function clickHandler ( event ) {
callback();
}
node.addEventListener( 'click', clickHandler, false );
return {
destroy () {
node.addEventListener( 'click', clickHandler, false );
}
};
}
}
};
</script>