穿透dom触发事件

const elems = document.elementsFromPoint(e.pageX, e.pageY);
const instance = elems.filter(elem => elem.classList.contains('meeting-hover-card'));
   if (instance.length > 0) {
           this.instance = instance[0];
           this.fireEvent(this.instance, 'mouseover');
    }

  使用document.elementsFromPoint能穿透获取dom节点,经过dispatchEvent模拟事件javascript

 const evObj = document.createEvent('Events');
    evObj.initEvent(eventName, true, false);
    elem.dispatchEvent(evObj);
相关文章
相关标签/搜索