useMouse

跟踪元素或文档主体上的鼠标位置。


import { useMouse } from 'primereact/hooks';
         

将鼠标悬停在元素上以跟踪鼠标位置。

X:0Y:0

const { ref, x, y } = useMouse();
         

提供 reset 回调以清除跟踪的鼠标位置。

X:0Y:0

const { ref, x, y } = useMouse();
         

当不使用 ref 时,将文档用作目标。

X:0Y:0

const { x, y } = useMouse();