javascript - 将 raphael js lib 包含到 android phonegap 应用程序中

标签 javascript android cordova raphael

我正在尝试在 android 上使用 phonegap 和 raphael js 运行一些性能测试,但是当我尝试运行应用程序 logcat 时出现以下错误:

03-20 19:52:15.095: D/CordovaLog(4208): Uncaught ReferenceError: Raphael is not defined 03-20 19:52:15.095:E/Web 控制台(4208):未捕获的引用错误:Raphael 未在文件中定义:///android_asset/www/js/classes/bootstrapper.js:58

我的 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 http-equiv="Content-Type" content="text/html; 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" />
        <title>Hello World</title>

        <script type="text/javascript" src="js/cordova/cordova-android-2.5.0.js"></script>
        <script type="text/javascript" src="js/libs/raphael-min.js"></script>
        <script type="text/javascript" src="js/libs/jquery-min.js"></script>
    </head>
    <body>
        <div class="app">
            <h1>Apache Cordova</h1>
            <div id="deviceready" class="blink">

                <p class="event listening"><a style="" href="informacoes.html">Ir para a p&aacute;gina de informa&ccedil;&otilde;es</a></p>
            </div>
        </div>     
        <script type="text/javascript" src="js/classes/bootstrapper.js"></script>


        <script type="text/javascript">

            app.testPeformance();
        </script>
    </body>
</html>

Bootstrap .js

var app = {

        testPeformance : function () 

        {

            // Creates canvas 320 × 200 at 10, 50
            var paper = Raphael(0, 0, 320, 320);

            for (var i = 0; i < 500 ; i++ )
            {
                x = Math.floor( ( Math.random() *320) +1);
                y = Math.floor( ( Math.random() *320) +1);

                // Creates circle at x = 50, y = 40, with radius 10
                var circle = paper.circle(x, y, 30);
                // Sets the fill attribute of the circle to red (#f00)
                circle.attr("fill", "#f00");

                // Sets the stroke attribute of the circle to white
                circle.attr("stroke", "#fff");

            }

        }

}

在IOS模拟器上完美运行。

提前致谢!

最佳答案

Android 用于 phonegap 应用程序的 Web 容器 (webkit) 似乎还不支持 SVG 图形 (android 2.2)。

:(

关于javascript - 将 raphael js lib 包含到 android phonegap 应用程序中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15533569/

相关文章:

java - Android - Java - 找不到处理 Intent 的 Activity

ios 在状态 "Preparing for Submission"时将应用程序从一个帐户转移到另一个帐户

javascript - 为什么 Javascript 小书签包含在闭包中?

java - 将可运行对象发布到 UI 线程后调用 wait() 直到完成

javascript - angularjs:用于显示一张图像与另一张图像的 if 语句

android - java.lang.IllegalStateException : SharedPreferences in credential encrypted storage are not available until after user is unlocked

java - Android View 的 HTML 5 数据属性的等价物

android - Facebook Connect/phonegap - FB.init 调用中的 "nativeInterface"参数,它的作用是什么?

javascript - 如何使用asp.net和jquery上传文件

javascript - 使用 CSS 和 JS 设置 SVG 样式