所以我在这里阅读这个问题:How to load another js file on a button click in titanium
有两种不同的方法可以打开钛合金窗户。我想知道每种打开窗户的方式是否有任何重大的性能差异或优势?我一直在看这里的文件:
http://docs.appcelerator.com/titanium/3.0/#!/api/Titanium.UI.Window
我也不使用Alloy。
任何人都知道使用每种方法有什么好处吗?代码片段如下。
方法1
var win = Ti.UI.createWindow({
backgroundColor : 'white',
url : 'home.js' //Path to your js file
});
win.open();
home.js
var myWin = Ti.UI.currentWindow;
//You can add your controls here and do your stuff.
// Note that never try to open myWin in this page since you've already opened this window
方法2
//In your current page
loginbutton.addEventListener('click', function(e) {
var Home = require('/ui/common/Home');
var homePage = new Home();
homePage.open();
});
Home.js
function Home() {
var self = Ti.UI.createWindow({
layout : 'vertical',
backgroundColor:'white'
});
//Do your stuff here
//Add other controls here
return self;
}
module.exports = Home;
答案 0 :(得分:0)