我试着在vue中播放鼠标中心事件的动画。但要做到这一点,我需要得到sections坐标。
<script setup>
function getCoords(e) {
const coords = { x: e.clientX, y: e.clientY } // This doesn't work ¯\_(ツ)_/¯
console.log(coords) // Error
// ...
}
</script>
<template>
<!-- ... -->
<section
@mouseenter="getCoords()" />
</template>我试过了,clientX,pageX,screenX,但是它们不起作用。那么,,,如何得到坐标?
发布于 2022-10-20 07:11:51
您需要从处理程序中删除():
<script setup>
function getCoords(e) {
const coords = { x: e.clientX, y: e.clientY }
console.log(coords)
// ...
}
</script>
<template>
<!-- ... -->
<section
@mouseenter="getCoords" />
</template>https://stackoverflow.com/questions/74135707
复制相似问题