IBM Worklight v 5.0.6 - 无法在 Windows Phone 7.5 环境中导航多页

2023-12-07

您好,我在 IBM Worklight v 5.0.6 中进行 WP 7.5 应用程序开发时遇到问题。 我使用了 MultiPageApp 项目ftp://public.dhe.ibm.com/software/mobile-solutions/worklight/docs/v506/wl_gs_all_samples.zip对于我的实验。

我遇到了很多问题:

第一个问题

我在worklight中搭建了WP 7.5环境,没有编辑代码。然后我在 MS Visual Studio 2012 中使用模拟器 7.1 256MB 运行它。问题是仅出现了 MultiPageApplication.html 的内容。

多页应用程序.html

<!DOCTYPE html>
<html>
    <head>
        <META http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <meta charset="utf-8">
        <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0" name="viewport">
        <title>MultiPageApplication</title>
        <link href="wlclient/css/wlclient.css" rel="stylesheet">
        <link href="images/favicon.png" rel="shortcut icon">
        <link href="images/apple-touch-icon.png" rel="apple-touch-icon">
        <link href="css/MultiPageApplication.css" rel="stylesheet">
        <script>

        // Define WL namespace.

        var WL = WL ? WL : {};



        /**

         * WLClient configuration variables.

         * Values are injected by the deployer that packs the gadget.

         */

        WL.StaticAppProps = {
   "APP_DISPLAY_NAME": "MultiPageApplication",
   "APP_SERVICES_URL": "http:\/\/169.254.17.188:8080\/apps\/services\/",
   "APP_VERSION": "1.0",
   "ENVIRONMENT": "windowsphone",
   "LOGIN_DISPLAY_TYPE": "embedded",
   "WORKLIGHT_ROOT_URL": "http:\/\/169.254.17.188:8080\/apps\/services\/api\/MultiPageApplication\/windowsphone\/"
};</script>
        <script src="wlclient/js/cordova.js"></script>
        <script src="common/js/wljq.js"></script>
        <script src="common/js/base.js"></script>
        <script src="wlclient/js/messages.js"></script>
        <script src="common/js/wlcommon.js"></script>
        <script src="wlclient/js/diagnosticDialog.js"></script>
        <script src="wlclient/js/deviceAuthentication.js"></script>
        <script src="wlclient/js/window.js"></script>
        <script src="wlclient/js/worklight.js"></script>
        <script src="wlclient/js/wlclient.js"></script>
        <script src="wlclient/js/wlfragments.js"></script>
        <script src="wlclient/js/encryptedcache.js"></script>
        <script src="wlclient/js/jsonstore/jsonstore.js"></script>
        <script src="wlclient/js/challengeHandlers/antiXSRFChallengeHandler.js"></script>
        <script src="wlclient/js/challengeHandlers/authenticityChallengeHandler.js"></script>
        <script src="wlclient/js/challengeHandlers/deviceAuthAutoProvisioningChallengeHandler.js"></script>
        <script src="wlclient/js/challengeHandlers/deviceAuthNoProvisioningChallengeHandler.js"></script>
        <script src="wlclient/js/challengeHandlers/remoteDisableChallengeHandler.js"></script>
        <script src="wlclient/js/wlgap-wp7.js"></script><script>window.$ = window.jQuery = WLJQ;</script>

    </head>
    <body id="content" style="display: none">

        <div id="AppBody">
            <!-- This is static header, it will be shown always -->

            <div id="header">

                <h1>Multi page app</h1>

            </div>

            <!-- This is a placeholder for dynamic page content -->

            <div id="pagePort"></div>
        </div>

        <script src="js/initOptions.js"></script>
        <script src="js/MultiPageApplication.js"></script>
        <script src="js/messages.js"></script>

    </body>
</html>

多页面Application.js

var pagesHistory = [];
var currentPage = {};

function wlCommonInit(){

    $("#pagePort").load("pages/MainPage.html", function(){
        currentPage.init();
    });
}

最后,我通过更改 jquery load API 的 URL(在 MS Visual Studio 2012 中手动)来解决这个问题

$("#pagePort").load("pages/MainPage.html",

to

$("#pagePort").load("default/pages/MainPage.html",

虽然代码可以工作,但另一个问题是

每次应用程序启动时都会重新生成native/www中的文件 已构建,因此对这些文件所做的任何更改都会丢失。

我应该怎么做才能正确生成URL?

第二个问题

当我想通过按“加载 Page1”按钮将页面从 MainPage.html 导航到 Page1.html 时,

Page1.html 不会加载,因为 MultiPageApplication.js 中的“init”方法不起作用。我从 MS Visual Studio 2012 的输出日志中收到此错误:

Log:"Error in error callback: File564653615 = TypeError: Object doesn't support property or method 'init'"

我尝试使用 jQueryMobile jquery-1.9.1.min.js 和 jquery.mobile-1.3.2.min.js 更改 Worklight 中嵌入的 jQuery,但出现了同样的问题。

那么,我应该如何解决这个问题呢?是因为 Worklight 中嵌入的 jQuery 在 Visual Studio 中不起作用吗?

Thanks


请尝试此处描述的解决方案:jQuery Mobile changePage() 在 Windows Phone 中不起作用

Namely:
open jquery.mobile-1.3.2.js并重构以下内容:

-        var uri = url ? this.parseUrl( url ) : location,
-          hash = this.parseUrl( url || location.href ).hash;
+        var uri = this.parseUrl( url || location.href ),
+          hash = uri.hash;

and:

-        return uri.protocol + "//" + uri.host + uri.pathname + uri.search + hash;
+        return uri.protocol + uri.doubleSlash + uri.host + uri.pathname + uri.search + hash;

请注意,我只用更改页面方法,但希望这可以修复所有内容的文件位置,包括您遇到的问题。

注意:请务必将应用程序恢复到原始状态。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

IBM Worklight v 5.0.6 - 无法在 Windows Phone 7.5 环境中导航多页 的相关文章

随机推荐