vue 用当前对象获取坐标距离
selectMeeting(day, jsEvent) {
//jsEvent 这个传进来就是$event
this.selectDay = day;
this.showMore=false;
this.meetingShowMore = true;
this.morePos = this.computePos(jsEvent.target);
//byludan 如果窗口到最右边往左移动
let totalMub=this.$refs.dates.getBoundingClientRect().width
let totalLeft=this.morePos.left
let totalWidth=226
if(totalLeft+totalWidth>totalMub){
this.morePos.left -= 189;
// console.log(‘morePos====’,totalMub-(totalLeft+totalWidth))
// console.log(‘ludanaaa11====’,jsEvent.target.getBoundingClientRect())
// console.log(‘ludanaaa====22’, this.$refs.dates.getBoundingClientRect())
// this.$emit(“meetingclick”, day.date, events, jsEvent);
}
// this.morePos.left -= 80;
// console.log('这里是当天的数据day===',day)
// console.log('这里是当天的数据jsEvent===',jsEvent)
let events = day.events.filter(item => {
return item.eventType == 'meeting';
});
}, //byludan end
//下面这个函数就是重点可以获取的左右坐标
computePos(target) {
let eventRect = target.getBoundingClientRect();
let pageRect = this.$refs.dates.getBoundingClientRect();
console.log()
return {
left: eventRect.left - pageRect.left,
top: eventRect.top + eventRect.height - pageRect.top
};
},
版权声明:本文由Web学习之路发布,如需转载请注明出处。