Skip to content

Vue源码相关

suyan edited this page Jun 17, 2022 · 1 revision

获取页面vue实例

var findVM = function(el) {
  if (!el) {
    return;
  }

  let children = el.children;
  if (!children) {
    return;
  }

  for (let i = 0; i < el.children.length; i++) {
    if (el.children[i].__vue__) {
      console.log(el.children[i].__vue__);
    }
    else {
      findVM(el.children[i]);
    }
  }
}

findVM(document.body);
Clone this wiki locally