0
我是鈦的初學者,我創建了新的移動應用程序項目並選擇了經典模板。鈦在窗戶之間導航時出錯
現在我有兩個Java腳本文件app.js和home.js 我想從app.js導航到home.js 這是我的代碼:
app.js
var window1 = Titanium.UI.createWindow({
title : 'Tab 1',
backgroundColor : '#fff',
layout : 'vertical'
});
var label = Titanium.UI.createLabel({
text : 'Log In:',
left : 'true',
color : '#000'
});
window1.add(label);
var tf_userName = Titanium.UI.createTextField({
color : '#000',
hintText : 'User Name',
width : '100%',
keyboardType : Titanium.UI.KEYBOARD_DEFAULT
});
window1.add(tf_userName);
var tf_password = Titanium.UI.createTextField({
color : '#000',
hintText : 'Password',
width : '100%',
passwordMask : true,
keyboardType : Titanium.UI.KEYBOARD_DEFAULT
});
window1.add(tf_password);
var loginButton = Titanium.UI.createButton({
title : 'Log In'
});
loginButton.addEventListener('click', function(e) {
var name = tf_userName.getValue();
var pass = tf_password.getValue();
alert('your name ' + name + ' pass ' + pass);
var Home = require('/jobchallenge/Resources/home.js');
var homePage = new Home();
homePage.open();
});
window1.add(loginButton);
window1.open();
home.js
function Home() {
Titanium.UI.setBackgroundColor('#000');
// create tab group
var tabGroup = Titanium.UI.createTabGroup();
//
// create base UI tab and root window
//
var win1 = Titanium.UI.createWindow({
title : 'Tab 1',
backgroundColor : '#fff'
});
var tab1 = Titanium.UI.createTab({
icon : 'KS_nav_views.png',
title : 'Tab 1',
window : win1
});
var label1 = Titanium.UI.createLabel({
color : '#999',
text : 'I am Window 1',
font : {
fontSize : 20,
fontFamily : 'Helvetica Neue'
},
textAlign : 'center',
width : 'auto'
});
win1.add(label1);
var win2 = Titanium.UI.createWindow({
title : 'Tab 2',
backgroundColor : '#fff'
});
var tab2 = Titanium.UI.createTab({
icon : 'KS_nav_ui.png',
title : 'Tab 2',
window : win2
});
var label2 = Titanium.UI.createLabel({
color : '#999',
text : 'I am Window 2',
font : {
fontSize : 20,
fontFamily : 'Helvetica Neue'
},
textAlign : 'center',
width : 'auto'
});
win2.add(label2);
tabGroup.addTab(tab1);
tabGroup.addTab(tab2);
return tabGroup;
}
module.exports = Home;
我的登錄按鈕按下時,得到這個錯誤
[ERROR] : TiExceptionHandler: (main) [0,13866] - Message: Uncaught Error: Requested module not found: /jobchallenge/Resources/home.js
[ERROR] : TiExceptionHandler: (main) [1,13867] - Source: throw new Error("Requested module not found: " + request);
[ERROR] : V8Exception: Exception occurred at ti:/module.js:280: Uncaught Error: Requested module not found: /jobchallenge/Resources/home.js
請幫忙嗎?