App中嵌套h5可以看到h5的打印日志

693 阅读1分钟

App中嵌套h5可以看到h5的打印日志方法

   <script>  
    (function () {  
      if (  
        ['地址'].test(window.location.href)  
      ) {  
        var script = document.createElement('script');  
        script.src = 'https://cdn.bootcdn.net/ajax/libs/eruda/2.3.3/eruda.min.js';  
        script.async = true;  
        document.getElementsByTagName('head')[0].appendChild(script);  
        script.onload = function () {  
          eruda.init({  
            container: document.querySelector('#_eruda'),  
          });  
        };  
      }  
    })();  
  </script> 

在 index.html 中引入上面的js代码就可以看到输出的 h5 日志,但是要注意将 编译时禁止打印 console.log() 的放发注释掉