English
useMouse
By webfansplz @webfansplz
We should focus on reusability when using Vue.js
. Composables are a great way to ensure this. Let's go 👇:
<script setup lang="ts">
// Implement ...
function useEventListener(target, event, callback) {
}
// Implement ...
function useMouse() {
useEventListener(window, "mousemove", () => {})
}
const { x, y } = useMouse()
</script>
<template>Mouse position is at: {{ x }}, {{ y }}</template>