如何在手机上调试

1.手机和电脑处于同一个wifi
2.在电脑上启动一个http server

npm i -g node-static
static --host-address=0.0.0.0

3.找到电脑的局域网IP,访问列如:http://192.168.5.14:8080/index.html
4.边预览边改代码

css:border大法
JS:alert大法/console.log大法

手机上没有console.log 方法,做了个console.log 方法

<style>
#console{
  background:#ccc;
  position:absolute;
  bottom:0;
  left:0;
  height:100px;
  width:100%;
}
</style>
<script>
  var div = document.createElement('div'); 
  div.id = 'console'; 
  document.body.appendChild(div);
  console.log = function(thing){
    div.innerText = JSON.stringify(thing)
  }
</script>

手机上就可以使用console.log方法了。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容