const that = this
that.$refs.container.onclick=function(ev){
var oEvent=ev||event;
var position = {
//oEvent.clientX 距离左边的位置 oEvent.clientY距离上边的位置
// that.$refs.container.getBoundingClientRect().left 元素距离浏览器左边的位置
left: (oEvent.clientX - (that.$refs.container.getBoundingClientRect().left || 0)),
top: (oEvent.clientY - (that.$refs.container.getBoundingClientRect().top || 0))
};
console.log(position);
}
网友评论