赞
踩
- import { onMounted,onUnmounted,reactive } from "vue";
- //需求:鼠标点击页面当中任意位置都可以获取坐标
- export default function usePoint(){
- const point=reactive({
- x:0,
- y:0
- })
- const getPoint=(event)=>{
- point.x=event.pageX
- point.y=event.pageY
- }
- onMounted(()=>{
- window.addEventListener('click',getPoint)
- })
- onUnmounted(()=>{
- window.removeEventListener('click',getPoint)
- })
- return point
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。