Ti.App.fireEvent-未定义参考错误Ti [英] Ti.App.fireEvent - Reference error Ti is not defined

查看:107
本文介绍了Ti.App.fireEvent-未定义参考错误Ti的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个简单的Titanium js脚本.

I have this simple Titanium js script.

app.js

var win = Ti.UI.createWindow();
    var webview = Ti.UI.createWebView({
        url: 'logging.html'
    });
    webview.addEventListener('help',function(){
        alert('help');
    });
    win.add(webview);
    win.open();

logging.html

logging.html

<html>
    <body>
        <a onclick="Ti.App.fireEvent('help')">Help</a>
    </body>
</html>

当我单击帮助"链接时,控制台会给我Reference Error: Ti is not defined.

when I click on the Help link, the console gives me Reference Error: Ti is not defined.

我也尝试过用钛代替钛,但是有同样的错误.

I also tried changing Ti with Titanium, but same error.

-------------编辑----------

------------- EDIT ----------

此错误仅与Web浏览器一起出现. iOS完美运行.但是

this error comes only with web browser. iOS works perfectly. but

推荐答案

我找到了解决方案!

将下面的简单脚本简单地添加到您的所有html页面中

simply add to all of your html pages the simple script below

var Ti = window.parent.Ti

玩得开心!

编辑:

从sdk版本3.0.2GA开始,我猜他们已经修复了它.现在它会在没有黑客攻击的情况下调用Ti sdk!**

这篇关于Ti.App.fireEvent-未定义参考错误Ti的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆