javascript - 在phonegap上使用afui和jquery时"Uncaught TypeError: Property ' touchLayer ' of object function ( selector, context )"

标签 javascript android jquery cordova appframework

我正在使用phonegap部署在Android上的afui(英特尔Appframework UI)中制作的Web应用程序,但是,当我在Android模拟器中测试它时,调试控制台在我刚刚启动应用程序后显示以下错误:

Uncaught TypeError: Property 'touchLayer' of object function (selector, context) 
    // The jQuery object is actually just the init constructor 'enhanced' 
    return new jQuery.fn.init( selector, context, rootjQuery ); 
} is not a function at file:///android_asset/www/ui/appframework.ui.js:3281

并且所有 JavaScript 功能都被禁用。

我不知道问题出在哪里。我已经在 Elementary OS 上的 chrome 中测试了该应用程序,它运行良好。

我使用的是phonegap 3.1.0-0.15.0、jQuery 1.10.2 和App Framework UI 2.0。

我按以下顺序导入 js 文件:

<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="js/jquery.js"></script>
<script src="js/jq.appframework.js"></script>
<script type="text/javascript" charset="utf-8" src="ui/appframework.ui.js"></script>

我希望有人能帮助我找到解决方案。

最佳答案

我也遇到了同样的问题。最终,查看 Appframework Kitchen Sink 中的 index.html,我发现要使错误消失,您需要在应用程序 index.html 中添加以下脚本:

var webRoot = "./";
$.ui.autoLaunch = false; //By default, it is set to true and you're app will run right away.  We set it to false to show a splashscreen
/* This function runs when the body is loaded.*/
var init = function () {
        $.ui.backButtonText = "Back";// We override the back button text to always say "Back"
        window.setTimeout(function () {
            $.ui.launch();
        }, 1500);//We wait 1.5 seconds to call $.ui.launch after DOMContentLoaded fires
    };
document.addEventListener("DOMContentLoaded", init, false);
$.ui.ready(function () {
    //This function will get executed when $.ui.launch has completed
});

我还不知道为什么需要这段代码,但它的使用也有记录 here

关于javascript - 在phonegap上使用afui和jquery时"Uncaught TypeError: Property ' touchLayer ' of object function ( selector, context )",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21129257/

相关文章:

javascript - 无法使用 JQuery $.each() 函数从 JSON 数据构建列表

android - 隐藏导航(系统)栏上的软键

javascript - 从 eBay 中的查找商品高级 API 返回商品属性

javascript - 请解释为什么它 "doesn' t 甚至改变数字的值是有意义的”

javascript - 使用 jQuery 更改 HTMLDivElement 中的所有 id

android - Cwac 相机添加缩略图

java - 响应数据未显示

javascript - event.target 没有给出所需的输出

javascript - 正确有效地实现后台加载

javascript - 无法在 JavaScript 中循环数组