mirror of https://github.com/sveltejs/svelte
37 lines
612 B
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>
|