我正在尝试在 webview 的 loadUrl("http://xyc.com/login.html")
html 页面的帮助下在 webview 中加载 login.html
有以下标签
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Hello </title>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<!--CSS linking -->
<link rel="stylesheet" href="assets/css/jquery.mobile-1.4.2.css" />
<link rel="stylesheet" href="assets/css/jquery-ui.css">
<link rel="stylesheet" href="assets/css/custom.css" />
</head>
<body>
<!-- jquery DOM element goes here-->
</body>
<!--Javascript linking -->
<script src="assets/js/jquery-1.9.1.js"></script>
<script src="assets/js/jquery-ui.js"></script>
<script src="assets/js/jquery.mobile-1.4.2.js"></script>
</html>
jQuery Mobile 中的方法无法始终如一地工作,我想知道是否是因为在 html 页面中加载 jquery
和 jquery-mobie
插件时的时间问题,或者这是 Android 4.3 webview 中的错误。它仅在 Adroid 4.2 和 4.3 webview 中发生。 Android logcat 显示以下错误
E/Web Console﹕ Uncaught TypeError: Object #<Object> has no method 'remove':12079
E/Web Console﹕ Uncaught TypeError: Object #<Object> has no method 'not':740
E/Web Console﹕ Uncaught TypeError: Object #<Object> has no method 'children':528
最佳答案
你测试这段代码:
<link rel="stylesheet" href="file:///android_asset/js/jquery.mobile-1.4.2.css">
<script src="file:///android_asset/js/jquery.js"></script>
<script src="file:///android_asset/js/jquery.mobile-1.4.2.js"></script>
或者使用:
<script>
javascript:loadScript('file:///android_asset/jquery.js','callback')
</script>
关于Android webview 未加载包含资源的完整 html 页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35770618/