天天看點

在Angular的index.html裡插入script,攔截所有動态建立标簽頁的場景

注意,下面這段代碼隻能插入在 Angular 應用的index.html裡,直接插入任何Component的index.html裡不會生效:

<script>
  console.log("Jerry");
  debugger;
  var scripts = document.querySelectorAll("script");
  var old = document.createElement;
  var _this = window.document;
  document.createElement = function(input){
    console.log("trying to create new tag: " + input);
    return old.call(_this, input);
  }
  debugger;
</script>      
在Angular的index.html裡插入script,攔截所有動态建立标簽頁的場景

繼續閱讀