내 아이폰 티타늄 앱에 변수를 전달하는 데 문제가 있습니다. 아래는 내 AppTabGroup.js 파일입니다. 'grantEntrance'라는 이벤트 리스너가 있습니다. 이 문제가 발생하면 모든 새 탭에 event.name 및 event.email 변수가 전달되어야합니다. 웬일인지 이것이 나를 위해 일하지 않고있다. 결국 정의되지 않은 오류가 발생합니다. 제 질문은 전역 변수를 어떻게 설정합니까? event.name과 마찬가지로 응용 프로그램의 어느 위치 에나 나타납니다.티타늄 - 변수를 새 창에 전달
function AppTabGroup() {
//declare module dependencies
var AppWindow = require('ui/AppWindow');
var OverviewWindow = require('ui/OverviewWindow');
var LeadWindow = require('ui/LeadWindow');
var CaseWindow = require('ui/CaseWindow');
var ResourcesWindow = require('ui/ResourcesWindow');
//create module instance
var self = Ti.UI.createTabGroup();
//create app tabs
var win1 = new OverviewWindow(L('Login')),
win2 = new CaseWindow(L('Cases'));
win3 = new LeadWindow(L('Leads'));
win4 = new ResourcesWindow(L('Resources'));
var tab1 = Ti.UI.createTab({
title: L('Login'),
icon: '/images/KS_nav_ui.png',
window: win1
});
win1.containingTab = tab1;
var tab2 = Ti.UI.createTab({
title: L('Cases'),
icon: '/images/KS_nav_views.png',
window: win2
});
win2.containingTab = tab2;
var tab3 = Ti.UI.createTab({
title: L('Leads'),
icon: '/images/KS_nav_views.png',
window: win3
});
win3.containingTab = tab3;
var tab4 = Ti.UI.createTab({
title: L('Resources'),
icon: '/images/KS_nav_mashup.png',
window: win4
});
win4.containingTab = tab4;
//Load Initial Login tab
self.addTab(tab1);
//If Login is successful then the below even will fire and the other tabs will be loaded
Ti.App.addEventListener('grantEntrance', function(event)
{
win2.name = event.name;
win2.email = event.email;
self.addTab(tab2);
self.addTab(tab3);
self.addTab(tab4);
self.removeTab(tab1);
});
return self;
};
module.exports = AppTabGroup;
다음은 내 CaseWindow.js 탭 다른 모든 JS 파일에서 사용할 수 있어야 app.js 파일에 정의
function AppWindow(title) {
var Main = Ti.UI.createWindow({
title:title,
backgroundColor:'white'
});
//Closed Case Button
var ccButton = Titanium.UI.createButtonBar({
labels:['Closed'],
backgroundColor:'#336699'
});
Main.setLeftNavButton(ccButton);
//New Case Button
var ncButton = Titanium.UI.createButtonBar({
labels:['New Case'],
backgroundColor:'#336699'
});
Main.setRightNavButton(ncButton);
ncButton.addEventListener('click', function() {
//containingTab attribute must be set by parent tab group on
//the window for this work
Main.containingTab.open(Ti.UI.createWindow({
title: L('newCaseWindow'),
backgroundColor: 'white'
}));
});
var msg = Titanium.UI.createLabel({
text:"Your Name is " + win.name,
//text:"You have successfully logged in. Upon logging in we sent back your email address and your name. You can pass all kinds of data simply by creating objects on your window.\n\nYour email is:\n" + email + "\n\nyour name is:\n" + name,
top:10,
left:10,
width:300,
height:'auto'
});
Main.add(msg);
return Main;
};
module.exports = AppWindow;
오류가 무엇이며 event.name 또는 event.email을 것입니다 : 여기에 정보를 저장하는 여러 방법에 대한 정보는
있다? 이벤트가 이메일, 이름을 어떻게 알 수 있습니까? –