我正在开发 PhoneGap应用程序并正在使用 jQuery Mobile 。上次我处理这个项目时,它看起来很棒,但现在 jQuery Mobile 停止工作了。这是怎么回事?
这是我的代码:
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0a3/jquery.mobile-1.0a3.min.css" />
<script type="text/javascript" src="http://code.jquery.com/jquery-1.5.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/mobile/1.0a3/jquery.mobile-1.0a3.min.js"></script>
</head>
<body>
<div id="page" data-role="page" data-theme="b">
<div data-role="content">
<h2>Login To Carpool Mobile</h2>
<p align="right"><a href="registration.html" id="showregistration">Don't have an account? →</a></p>
<form method="post" id="loginForm">
<label for="password">Email:</label>
<input class="required" type="text" name="username" id="username" placeholder="<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="86f3f5e3f4e8e7ebe3c6f2e7f4e1e3f2a8e5e9eb" rel="noreferrer noopener nofollow">[email protected]</a>">
<label for="password">Password:</label>
<input class="required" type="password" name="password" id="password" placeholder="password">
<input type="button" value="Login" id="submitButton" onClick="handleLogin()">
</form>
</div>
</div>
<script>
$(document).ready(function() {
checkPreAuth();
});
</script>
</body>
</html>
最佳答案
PhoneGap 要求您在根目录的“config.xml”文件中手动设置/允许应用程序的各个方面。
我相信您正在寻找的解决方案是这一行:
<access origin="http://code.jquery.com" subdomains="true" />
您允许访问“http://code.jquery.com ”的外部资源并允许其所有子域。这意味着您刚刚解锁了 jquery mobile,这就是您想要的,如脚本标记所示:
<script type="text/javascript" src="http://code.jquery.com/jquery-1.5.min.js"></script> <script type="text/javascript" src="http://code.jquery.com/mobile/1.0a3/jquery.mobile-1.0a3.min.js"></script>
These "src" attributes are now seen as "subdomains" of http://code.jquery.com, which you have just successfully allowed!
关于android - jQuery Mobile 无法与 PhoneGap 配合使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15510100/