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;
    }
  }
// 是否销毁元素

 

posted @ 2020-11-11 17:45  悔创阿里-杰克马  阅读(268)  评论(0编辑  收藏  举报
求投食~(点图即可)