-1

hey all, how to navigate/call other .js file after click event on button. once it ciick it will goes to other window. osplease help me to solve this problem

thanks,

4

1 回答 1

1

请在下面找到一个以 iOS 为重点的快速示例。Kitchen Sink 示例应用程序中还有更多可用的应用程序: https ://github.com/appcelerator/titanium_mobile/tree/master/demos/KitchenSink

脚步:

1)创建钛移动项目

2)在 app.js 文件中添加以下内容

var winPage1 = Ti.UI.createWindow({
    url:'page1.js', title:'第1页'
});

winPage1.open();

3) 在与app.js 相同的目录中添加一个名为page1.js 的文件,然后将其粘贴到

var win = Ti.UI.currentWindow;

(功能(){
    var b1 = Ti.UI.createButton({
        标题:“按我”,
        左:10,上:100,右:10,高度:40
    });
    b1.addEventListener('click', function(e) {
        var wPage = Ti.UI.createWindow({
                标题:'测试页2',
                背景颜色:'黄色',
                网址:'page2.js'
        });

        wPage.open({modal:false});
    });

    win.add(b1);

})();

4) 在与app.js 相同的目录中添加一个名为page2.js 的文件,然后将其粘贴到

var win = Ti.UI.currentWindow;

(功能(){
    var b1 = Ti.UI.createButton({
        标题:“按我”,
        左:10,上:100,右:10,高度:40
    });
    b1.addEventListener('click', function(e) {
        赢.close();
    });

    win.add(b1);

})();

5) 在 Titanium Developer 或 Studio 中运行

这应该给你一个运行相同的显示如何打开和关闭窗口。厨房水槽(上面的链接)有更多的样品展示了不同的方法来做到这一点。

于 2011-04-29T17:14:20.143 回答