Vue function that tracks the mouse x
and y
position in the document.
function useMouse(): {
docX: Ref<number>
docY: Ref<number>
}
docX: Ref<number>
the mousex
position relative to the documentdocY: Ref<number>
the mousey
position relative to the document
<template>
<div>docX docY: {{ docX }}px {{ docY }}px</div>
</template>
<script lang="ts">
import Vue from 'vue'
import { useMouse } from 'vue-use-kit'
export default Vue.extend({
name: 'useMouseDemo',
setup() {
const { docX, docY } = useMouse()
return { docX, docY }
}
})
</script>