在头部添加javascript标签时,我的页面不会显示 - jQuery Mobile

问题描述 投票:-2回答:1

如果不将[javascript file.js]标记添加到我的代码的标题中,我的jquery移动页面就会显示出来。但是,当我将标记添加到标题中时,我的页面只显示一个空白,并且不显示任何信息。

我究竟做错了什么?

我已经尝试在jquery移动插件之前添加标签,之后等,但它显示的页面没有我的jquery主题的皮肤。

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=yes">
    <link rel="stylesheet" href="css/themes/blue.min.css" />
    <link rel="stylesheet" href="css/themes/jquery.mobile.icons.min.css" />
    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.5/jquery.mobile.structure-1.4.5.min.css" />
    <script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
    <script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
    <script src="images.js"></script>
    <title>House 1</title>
</head>

Javascript文件

$(document).ready(function () {
    var i = 0;
    var imgURL = [];

    imgURL.push('pictures/houses/house1/image1.PNG');
    imgURL.push('pictures/houses/house1/image2.PNG');

    $("#house1").swiperight(function () {
        if (i < (imgURL.length - 1)) {
            i++
        } else {
            i = 0;
        }
        var imgStr = "<img src=" + imgURL[i] + " style='width:100%'>";
        $('#popupImg').html(imgStr);
    });
    $("#house1").swipeleft(function () {
        if (i > 0) {
            i--
        } else {
            i = (imgURL.length - 1);
        }
        var imgStr = "<img src=" + imgURL[i] + " style='width:100%'>";
        $('#popupImg').html(imgStr);
    });
});

页面应该能够正常查看而不是显示空白页面。

javascript css jquery-mobile
1个回答
1
投票

在为自定义代码添加<script>标记之前,请务必加载所有库和依赖项。如果已经解决,请将答案粘贴到您的问题上?这极大地帮助了社区学习。

© www.soinside.com 2019 - 2024. All rights reserved.