Skip to content

useMouse medium #Composable Function

By webfansplz @webfansplz

Take the Challenge    简体中文

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>


Share your Solutions Check out Solutions