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-context/main.html

29 lines
472 B

<button on:tap='set({ z: event.answer })'>{{z}}</button>
<script>
export default {
data: () => ({
z: '???',
answer: '42'
}),
events: {
tap ( node, callback ) {
const clickHandler = event => {
callback({
answer: this.get( 'answer' )
});
};
node.addEventListener( 'click', clickHandler, false );
return {
teardown () {
node.addEventListener( 'click', clickHandler, false );
}
};
}
}
};
</script>