<script setup>
import { ref, onMounted, onUnmounted } from 'vue'
const x = ref(0)
const y = ref(0)
function update(event) {
x.value = event.pageX
y.value = event.pageY
}
onMounted(() => window.addEventListener('mousemove', update))
onUnmounted(() => window.removeEventListener('mousemove', update))
</script>
<template>Mouse position is at: {
{ x }}, {
{ y }}</template>
vue3鼠标追踪器
猜你喜欢
转载自blog.csdn.net/m0_45865109/article/details/129137120
今日推荐
周排行