<script>
let m = { x: 0, y: 0 };
const handleMousemove = (event) => {
m.x = event.clientX;
m.y = event.clientY;
}
</script>
<style>
div { width: 100%; height: 100%; }
</style>
<div on:mousemove={handleMousemove}>
The mouse position is {m.x} x {m.y}
</div>
<script>
function handleDeleteClick(id) {
...
deleteFunction(id) // id값을 전달받아 사용
}
</script>
...
<button on:click={() => handleDeleteClick(id)} >삭제</button>
// 기본
<script>
function fnCall() {
...
}
</script>
<button on:click={fnCall} >Call</button>
// param 이 있는 경우
<script>
function fnCall(param) {
...
}
</script>
<button on:click={() => fnCall(param)} >Call</button>
// 예외경우
<script>
export let Todo
function fnCall(param) {
...
}
</script>
<button on:click={fnCall(Todo.id)} >Call</button>