Appcelerator Titanium createWindow()无法打开新窗口,错误

时间:2014-07-14 10:32:33

标签: javascript titanium

我是Titanium 3.x的新手,我已经完成了我的第一个简单的Titanium项目。它只是使用另一个JS文件打开新窗口。 我在index.js中编写代码,如下所示。 我在app / controllers /.

中创建了新的js文件“createnew.js”
//////////////////////////////////////
button.addEventListener('click',function(e)
{
    var childWindow = Ti.UI.createWindow({
        url: 'createnew.js'
    });
    childWindow.open();

});
///////////////////////////////////////
// createnew.js
///////////////////////////////////////


        var self = Ti.UI.createWindow();

        var overview = Ti.UI.createView({
            width: Ti.UI.FILL,
            height: Ti.UI.FILL,
            backgroundColor: 'yellow'

        });
    self.add(overview);

    self.open();

运行app时,如果单击按钮,模拟器中会出现红色错误窗口,表示无法打开createnew.js文件,找不到此类文件或目录。

我该如何解决这个问题?

我的目标是将Mobile应用程序的每个页面都设置为不同的Js文件,当它进入页面时,我可以使用调用createWindow()来加载Js文件。 请帮帮我。

1 个答案:

答案 0 :(得分:1)

您写道:

  

我在app / controllers /.

中创建了新的js文件“createnew.js”

所以看来你正在关注允许的Titanium框架。 但是使用编码风格,你似乎正在使用经典的Titanium结构。

请不要混淆并遵循以下链接的Titanium编码风格: