手机端由原生切换为 H5, 定位不到元素. 需要将 apk 开启调试模式: 在入口 Activity 中添加 2 行代码, 如下
- if (Build.VERSION.SDK_INT>=Build.VERSION_CODES.KITKAT) {
- webView.setWebContentsDebuggingEnabled(true);
- }
效果如下:
- protected void onCreate(Bundle savedInstanceState) {
- setContentView(R.layout.activity_main);
- super.onCreate(savedInstanceState);
- context = this;
- if (Build.VERSION.SDK_INT>=Build.VERSION_CODES.KITKAT) {
- WebView.setWebContentsDebuggingEnabled(true);
- }
- ......
- ......
来源: http://www.bubuko.com/infodetail-2772119.html