Open
Description
<script setup lang="ts">
import { ref } from 'vue'
// Implement ...
function useEventListener(target, event, callback) {
target.addEventListener(event, callback)
}
// Implement ...
function useMouse() {
const x = ref(0)
const y = ref()
useEventListener(window, "mousemove", (event) => {
x.value = event.clientX
y.value = event.clientY
})
return { x, y }
}
const { x, y } = useMouse()
</script>
<template>
Mouse position is at: {{ x }}, {{ y }}
</template>