我正在使用Atom编辑器和PhoneGap,但我的jQuery和jQuery Mobile无法正常工作。所有.js文件都在名为js的文件夹中,并且根目录链接正确。我尝试了在线的code.jquery.com版本,但仍然无法工作。这是我尝试过的两个版本:
我使用这段代码来测试我的jQuery是否正常工作。
版本1
`<link rel="styleheet" type="text/css" href="css/jquery.mobile-
1.4.5.min.css">
<link rel="styleheet" type="text/css" href="css/jquery.mobile-1.4.5.css">
<link rel="stylesheet" type="text/css" href="css/index.css" />
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="js/index.js"></script>
<script type="text/javascript"> app.initialize();</script>
<script type="text/javascript" src="js/jquery.mobile-1.4.5.min.js">
</script>
<script type="text/javascript" src="js/jquery.mobile-1.4.5.js"></script>
<script type="text/javascript" src="js/jquery-3.2.1.min.js"></script>
`
版本2
<link rel="stylesheet"
href="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css"/>
<script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-
1.4.5.min.js"></script>
<script
src="https://code.jquery.com/jquery-3.2.1.min.js"
integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
crossorigin="anonymous"></script>
<link rel="stylesheet" type="text/css" href="css/index.css" />
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="js/index.js"></script>
<script type="text/javascript">app.initialize();</script>
我使用这段代码来测试我的jQuery是否正常工作。
`<script>
window.onload = function(){
if (window.jquery){
alert("YES");
}else {
alert("ERROR");
}
}
</script>
`
每次都出现错误。我进行编程,从未出现过错误。