Files
knowledge-kit/Chapter1 - iOS/1.4.md
2020-02-25 17:46:51 +08:00

18 lines
1.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 如何优雅地调试手机网页
> 在web开发的过程中抓包、调试页面样式、查看请求头是很常用的技巧。其实在iOS开发中这些技巧也能用无论是模拟器还是真机不过我们需要用到mac自带的浏览器Safari。所以本文将讲解如何使用Safari对iOS程序中的webview进行调试。
* 1、打开真机模拟器的开发者模式
【设置】-> 【Safari】 -> 【高级】 -> 【Web检查器】打开
![打开手机的调试模式](https://raw.githubusercontent.com/FantasticLBP/knowledge-kit/master/assets/2287777-e937adb9c77a3768.png)
* 2、打开MBP上的Safari的开发者模式
【Safari】->【偏好设置】->【高级】-> 【在菜单栏中显示“开发”菜单】勾选。
* 3、调试你的WebView页面。
* 4、在MBP的Safari选项中的开发看到手机右击可以看到正在调试的WebView的url
![选择需要调试等页面](https://raw.githubusercontent.com/FantasticLBP/knowledge-kit/master/assets/2287777-c12eb2da00e79f34.png)
* 5、在弹出的这个框里面可以查看网页源代码以及可以调试样样式、查看localStorage、sessionStorage、Cookie的值等等给原生端调试带来很大方便不过这样前端调试更加方便啊谷歌的模拟器不能完全模真实环境下的iphone使用效果啊。
![调试手机页面](https://raw.githubusercontent.com/FantasticLBP/knowledge-kit/master/assets/2287777-4d55fd205fa81cc8.png)