0

我正在使用新发布的 kendoui 2013、phonegap 2.6.0、ios 模拟器 6.1 和 iphone 4s(ios 6.1)。

我尝试了两种方法:1)使用phonegap生成的index.html并手动添加kendoui css和javascript。2) 编写一个没有phonegap javascript 的简单kendoui index.html。

两种方式都将挂在开始屏幕上(尚未显示 index.html)。但是如果我删除下面的代码,它就不会挂起,而是会显示 index.html。

var app = new kendo.mobile.Application();

然后我在代码下添加一个警报:

var app = new kendo.mobile.Application();
alert("ddddd");

警报将显示在开始屏幕上,但它仍会挂在开始屏幕上并且不会显示 index.html。

kendoui初始功能中似乎有一些异步任务,并且无法在设备上完成。

index.html 的源代码:

<!DOCTYPE html>
<!--
    Licensed to the Apache Software Foundation (ASF) under one
    or more contributor license agreements.  See the NOTICE file
    distributed with this work for additional information
    regarding copyright ownership.  The ASF licenses this file
    to you under the Apache License, Version 2.0 (the
    "License"); you may not use this file except in compliance
    with the License.  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing,
    software distributed under the License is distributed on an
    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
     KIND, either express or implied.  See the License for the
    specific language governing permissions and limitations
    under the License.
-->
<html>
    <head>
        <meta charset="utf-8" />
        <meta name="format-detection" content="telephone=no" />
        <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
        <!-- <link rel="stylesheet" type="text/css" href="css/index.css" /> -->
        <link href="1/css/kendo.mobile.all.min.css" rel="stylesheet" />
        <title>Hello World</title>
    </head>
    <body>
        <div data-role="view" id="home">
            <header data-role="header">
                <div data-role="navbar">
                    dddd
                </div>
            </header>
        </div>
        <script type="text/javascript" src="cordova-2.6.0.js"></script>
        <script src="1/js/jquery.min.js"></script>
        <script src="1/js/kendo.all.min.js"></script>
        <script type="text/javascript" src="js/index.js"></script>
        <script type="text/javascript">
            app.initialize();
            var app = new kendo.mobile.Application();
        </script>
    </body>
</html>

有什么建议可以解决这个问题吗?

4

2 回答 2

4

除了删除 app.initialize(),您还需要移动 var app = new kendo.mobile.Application(); 对 PhoneGap 的deviceready事件的初始化调用。

<script>

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

    function onDeviceReady() {

        // Now safe to use the Cordova API
        var app = new kendo.mobile.Application();
    }

</script>
于 2013-04-12T14:39:21.753 回答
1

在分配之前,您正在尝试使用 app 的方法。此外,Kendo UI Mobile 的应用程序中没有这样的方法。只需删除 app.initialize() 行,您的应用程序可能就可以工作了。

于 2013-04-12T12:29:09.973 回答