let a = window.parent.document.querySelector(‘#uiWin‘).getBoundingClientRect();
//获得窗口div坐标及大小(支持浏览器任意情况)
VideoPoint(e: MouseEvent) {
let videoLoaction = this.$refs[‘refVideo‘] as any;
let h = videoLoaction.offsetHeight;//div 高度
let w = videoLoaction.offsetWidth;//div 宽度
let y = videoLoaction.offsetTop;//div左上y坐标
let x = videoLoaction.offsetLeft; //div左上x坐标
let xParam = (e.screenX - e.clientX);
let yParma = (e.screenY - e.clientY);
let obj = { x: x + xParam , y: y + yParma, w: w, h: h };
console.log(JSON.stringify(obj));
return obj;
}
原文:https://www.cnblogs.com/anjun-xy/p/14646569.html