contains判断是否点击是否属于在该元素内
function contains(root, n) { let node = n; while (node) { if (node === root) { return true; } node = node.parentNode; } return false; }
// dom contains源码
getContainer() { if (!this.cmContainer) { this.cmContainer = document.createElement('div'); document.body.appendChild(this.cmContainer); } return this.cmContainer; } componentWillUnmount() { if (this.cmContainer) { ReactDOM.unmountComponentAtNode(this.cmContainer); document.body.removeChild(this.cmContainer); this.cmContainer = null; } } // 是否销毁元素