mounted() { document.addEventListener("click", (e) => this.fintParent(e)); }, methods: { fintParent(e) { const clickNode = e.srcElement; let parent = clickNode.parentNode; while (parent) { if ( parent.classList && (parent.classList.contains("dropdownWrap") || parent.classList.contains("p_more-service")) ) { break; } parent = parent.parentNode; } if (!parent) { this.visible = false; } }
}
标签:contains,parent,classList,元素,点击,clickNode,某个,fintParent From: https://www.cnblogs.com/hwy6/p/17276556.html