我正在使用 Apache Cordova 制作 Android 应用程序。在默认使用 Chrome 的 Android 6.0 上一切正常,问题出在使用默认 Android 浏览器的 Android 4.2.2(三星 Galaxy S4 mini)上。
如果我没记错的话,那么应用程序在使用 cordova 编译并安装在 Android 操作系统上后,就会在默认的 Android 浏览器中“启动”。
在默认的 Android 浏览器中,加载时页面为空。但在 Chrome 中一切正常。
问题出在默认的 Android 4.2.2 浏览器中。它无法在 Nokia 1520(使用 Windows Phone 操作系统)的默认浏览器中运行。
索引.html:
<!DOCTYPE html>
<html>
<head>
<script src="js/jquery-3.1.1.min.js" type="text/javascript"></script>
<script src="2.js" type="text/javascript"></script>
<script src="1.js" type="text/javascript"></script>
</head>
<body>
<div id="content">
</div>
</body>
</html>
1.js:
$(document).ready(function() {
$('#content').html("<span>test3</span>"); // Works fine (i can see test3 on the page).
showLogin();
});
2.js(此文件中的任何内容都不起作用,我在页面上看不到 test1 或 test2):
$('#content').html("<span>test1</span>");
function showLogin() {
$('#content').html(`<span>
test2
</span>`);
}
我尝试过#1
我也尝试致电showLogin()
inside setTimeout()
:
setTimeout(function() {
showLogin();
}, 1000);
我尝试过的#2
1.js:
$(document).ready(function() {
$('#content').html("<span>test3</span>"); // Works fine.
showLogin();
});
2.js(此文件中没有任何内容):
$(document).ready(function() {
$('#content').html("<span>test1</span>");
function showLogin() {
$('#content').html(`<span>
test2
</span>`);
}
});