gpt4 book ai didi

javascript - Phonegap - JavaScript 不工作

转载 作者:行者123 更新时间:2023-12-03 07:20:42 24 4
gpt4 key购买 nike

我遇到一个问题,当我尝试构建phonegap 并在我的Android 手机上测试它时,javascript 无法运行。

我有简单的 config.xml 文件,并且有我的 index.html 头部的预览:

<!doctype html>
<html lang="fr">
<head>
<meta charset="utf-8">
<title>My app</title>

<script type="text/javascript" charset="utf-8" src="cordova.js"></script>
<script type="text/javascript" src = "phonegap.js" > </script>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1, minimum-scale=1, user-scalable=yes">
<link href='https://fonts.googleapis.com/css?family=Quicksand' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="Mobile_style.css"><link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script type="text/javascript" src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css">
<link href='https://fonts.googleapis.com/css?family=Quicksand:700' rel='stylesheet' type='text/css'>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script type="text/javascript" charset="utf-8" src="cordova.js"></script>
<script type="text/javascript" src = "phonegap.js" > </script>
<script type="text/javascript" charset="utf-8">

function onBodyLoad()
{
document.addEventListener("deviceready", onDeviceReady, false);
}


function onDeviceReady()
{
// do your thing!
}
</script>

<script type="text/javascript">
window.onload = function()
{

MY JS CODE

}
</script>
</head>
<body onload="onBodyLoad()">

MY HTML

</body>

我有两个 html 文件,index.html 和 game.html,我在游戏的头部有相同的链接和脚本。

我尝试将我的代码放在上面,但那不起作用。

我搜索了几个小时,但我可以解决问题。

感谢您的帮助!

最佳答案

您应该只包含一个版本的 jquery。另外,您不需要同时使用 cordova.js 和phonegap.js,请选择一个脚本。

您的代码可能看起来更简洁:

<!doctype html>
<html lang="fr">
<head>
<meta charset="utf-8">
<title>My app</title>


<meta name="viewport"
content="width=device-width, initial-scale=1.0, maximum-scale=1, minimum-scale=1, user-scalable=yes">

<link rel="stylesheet" href="Mobile_style.css">
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css">
<link href='https://fonts.googleapis.com/css?family=Quicksand:700' rel='stylesheet' type='text/css'>

<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>
<script type="text/javascript" src="phonegap.js"></script>

<script type="text/javascript" charset="utf-8">

document.addEventListener("deviceready", onDeviceReady, false);

function onDeviceReady() {
alert("Device is ready");
}

</script>
</head>
<body>

MY HTML

</body>
</html>

关于javascript - Phonegap - JavaScript 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36230671/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com