mirror of https://github.com/sveltejs/svelte
35 lines
613 B
35 lines
613 B
{{#each items as item}}
|
|
<button on:tap='set({ fromDom: this.textContent, fromState: item })'>{{item}}</button>
|
|
{{/each}}
|
|
|
|
<p>fromDom: {{fromDom}}</p>
|
|
<p>fromState: {{fromState}}</p>
|
|
|
|
<script>
|
|
export default {
|
|
data: () => ({
|
|
x: 0,
|
|
y: 0,
|
|
fromDom: '',
|
|
fromState: '',
|
|
items: [ 'foo', 'bar', 'baz' ]
|
|
}),
|
|
|
|
events: {
|
|
tap ( node, callback ) {
|
|
function clickHandler ( event ) {
|
|
callback();
|
|
}
|
|
|
|
node.addEventListener( 'click', clickHandler, false );
|
|
|
|
return {
|
|
teardown () {
|
|
node.addEventListener( 'click', clickHandler, false );
|
|
}
|
|
};
|
|
}
|
|
}
|
|
};
|
|
</script>
|