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

查看:28
本文介绍了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.

我也试过用 Titanium 改变 Ti,但同样的错误.

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 没有那个 hack!**

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

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