天天看点

在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,拦截所有动态创建标签页的场景

继续阅读